...
Warning |
---|
Attention: All scripts in this page are assuming that your current shell is Bash. - If you are using some other shell such as tcsh, you can switch to bash in your current session by typing "bash" in your terminal.
- If you wish to switch permanently to Bash as your default shell here are some instructions:
In order to change your default shell at login from tcsh (or any other shell) to Bash, please execute the following command on a Linux server on the AFS network, such as a rhel6-64* node. (You will be prompted for your password during this process): After that, close the terminal and open a new one. You will be using Bash as the default shell. You can check if all went well with the following command in a new Terminal window: |
Python with MATLABWe can directly call Python library functionality from MATLAB or write Python programs that work with MATLAB.
For information on compatible Python versions, refer to the link: https://www.mathworks.com/support/requirements/python-compatibility.html
To check the Python version in MATLAB, use the following command:
Code Block |
---|
|
>> pyenv
ans =
PythonEnvironment with properties:
Version: "3.8"
Executable: "/usr/local/lcls/package/anaconda/envs/python3_env/bin/python"
Library: "/usr/local/lcls/package/anaconda/envs/python3_env/lib/libpython3.8.so"
Home: "/usr/local/lcls/package/anaconda/envs/python3_env"
Status: NotLoaded
ExecutionMode: InProcess |
Note |
---|
The library conflicts between MATLAB's and Python's libraries can result in segmentation faults. |
If the Python version in the MATLAB environment differs from the one in the Linux environment (the version used in DEV and PROD, you need to update the "startup.m" file located at "$TOOLS/matlab/toolbox/."
Code Block |
---|
|
# A snippet of the file:
if strcmp(version('-release'),'2020a') | strcmp(version('-release'),'2022b') | strcmp(version('-release'),'2023a')
% Setup Python Environment:
package_top = getenv('PACKAGE_TOP');
pyenv_path = [package_top '/anaconda/envs/python3_rhel7_env/bin/python'];
pyenv('Version', pyenv_path,'ExecutionMode','InProcess');
%% Change default add-ons installation folder for Monkey Proof Code Checker
theSettings = settings();
theSettings.matlab.addons.InstallationFolder.TemporaryValue = [package_top '/matlab/2020a/SupportPackages'];
end |
matpva- matpva is a powerful extension that provides seamless integration between MATLAB and EPICS 7 through the Python P4P module.
How to use matpva
matpvaMatpva: Integrate EPICS7 into MATLAB using PVAccess for Python (P4P) module
Link to the GitHub Repository: https://github.com/slaclab/matpva
How to test matpva
How to test matpva Matpva in DEV and PROD (lcls and facet)
...
MATLAB R2020a
MATLAB R2022b
MATLAB R2023a
Anchor |
---|
| matlab_installation |
---|
| matlab_installation |
---|
|
Installation
...
- New versions (versions later than 2012a) of MATLAB should be installed in the 3rd-party software package area under the matlab folder:
- Development: /afs/slac/g/lcls/package/matlab
- Production: /usr/local/lcls/package/matlab - Inside the matlab directory, versions should be installed in folders that correspond to their MATLAB version, e.g. 2012a, 2019a, 2020a, 2022b, 2023a etc.
At the time of this writing, the latest version of MATLAB deployed for LCLS Development and Production is 2022b2023a.
Individual AFS user accounts in the LCLS Development environment default to set up and use MATLAB 2012a 2020a unless overridden.
The default MATLAB versions for shared login accounts in Production are as follows:
Account | Default MATLAB version |
---|
physics | 2012a2020a |
softegr | 2019a2020a |
laci | 2012a |
Anchor |
---|
| matlab_license |
---|
| matlab_license |
---|
|
License servers for Matlab network licensesIn order to support the latest version of Matlab, the network license service had to be migrated to a newer operating system. The new service is running on servers license701, license702, and license703 (replacing license1, license2, and license3).
Linux users using bash or similar shells should update their environment with the command:
Code Block |
---|
|
export MLM_LICENSE_FILE=27010@license701,27010@license702,27010@license703 |
If you are using csh or tcsh, the equivalent command is:
Code Block |
---|
|
setenv MLM_LICENSE_FILE "27010@license701,27010@license702,27010@license703" |
https://slacprod.servicenowservices.com/kb_view.do?sysparm_article=KB0011921
Anchor |
---|
| running_matlab |
---|
| running_matlab |
---|
|
Running MATLAB
Code Block |
---|
|
# Launch in desktop mode:
$ run_matlab.bash -m <matlab_version> -d # ex) run_matlab.bash -m 2023a -d
# Launch in terminal mode:
$ run_matlab.bash -m <matlab_version> # ex) run_matlab.bash -m 2023a |
To use one of the supported versions of MATLAB for development and configuration setup purposes, you need to set up your environment following follow the appropriate setup procedures.
Development (MATLAB should be run on lcls-dev3 in DEV. Do not run MATLAB instances on login nodes such as centos7.)
Code Block |
---|
|
$ source /afs/slac/g/lcls/epics/setup/epicsenv-7.0.3.1-1.0.bash
$ source /afs/slac/g/lcls/tools/oracle/oracleSetup-R11.2.0.4.bash
$ export MATLAB_VER=<matlab_version> # Currently supported MATLAB versions: 2020a, 2022b, 2023a
$ export MLM_LICENSE_FILE="27010@license701,27010@license702,27010@license703"
$ source /afs/slac/g/lcls/tools/matlab/setup/matlabSetup64.bash
# Launch in desktop mode:
$ LD_PRELOAD=${FACILITY_ROOT}/epics/base/R7.0.3.1-1.0/lib/rhel7-x86_64/libCom.so matlab &
$ LD_PRELOAD=${FACILITY_ROOT}/epics/base/R7.0.3.1-1.0/lib/rhel7-x86_64/libCom.so /afs/slac/g/lcls/package/matlab/<matlab_version>/bin/matlab & # If "matlab &" couldn't find the correct location, use the absolute path
$ run_matlab.bash -m <matlab_version> -d # ex) run_matlab.bash -m 2023a -d
# Launch in terminal mode:
$ run_matlab.bash -m <matlab_version> # ex) run_matlab.bash -m 2023a |
Production (Run on softegr@lcls-srv01 or physics@lcls-ssrv01 in PROD. Do not run MATLAB instances on mcclogin.)
Code Block |
---|
|
$ source /usr/local/lcls/epics/epicsenv-7.0.3.1-1.0.bash
$ source /usr/local/lcls/tools/oracle/oracleSetup-R11.2.0.4.bash
$ export MATLAB_VER=<matlab_version> # Currently supported MATLAB versions: 2020a, 2022b, 2023a
$ source /usr/local/lcls/tools/matlab/setup/matlabSetup64.bash
# Launch in desktop mode:
$ LD_PRELOAD=${FACILITY_ROOT}/epics/base/R7.0.3.1-1.0/lib/rhel7-x86_64/libCom.so matlab &
$ LD_PRELOAD=${FACILITY_ROOT}/epics/base/R7.0.3.1-1.0/lib/rhel7-x86_64/libCom.so /usr/local/lcls/package/matlab/<matlab_version>/bin/matlab & # If "matlab &" couldn't find the correct location, use the absolute path
$ run_matlab.bash -m <matlab_version> -d # ex) run_matlab.bash -m 2023a -d
# Launch in terminal mode:
$ run_matlab.bash -m <matlab_version> # ex) run_matlab.bash -m 2023a |
Anchor |
---|
| configuring_matlab |
---|
| configuring_matlab |
---|
|
Configuring MATLAB
...
Warning |
---|
Never try to modify the existing global configuration files. If you need changes made to the global configuration files, consult the MATLAB admins for LCLS Development and Production (TID-ACS and EED Systems Group). Any changes to the global MATLAB configuration must be approved and implemented by those groups. |
Known issues1. When MATLAB 2022b starts, you will see the following error message: Warning: X does not support locale en_US.UTF-8
This is a known issue in MATLAB R2022b Update 5. The bug that triggers the warning when starting up MATLAB will be resolved in the upcoming update.
https://www.mathworks.com/matlabcentral/answers/1929870-why-do-i-get-warning-on-startup-x-does-not-support-locale-en_us-utf-8-when-startup-matlab-with-r2?s_tid=answers_rc1-2_p2_MLT
The bug has been resolved in the following versions: R2023b, R2023a Update 3, and R2022b Update 6.
2. When using matpva in MATLAB and then exiting, it generates a segmentation violation message. While labCA closes, it displays the message "Entering labca finalizer." Ideally, it should complete this process and then show another message, such as "Leavving labca finalizer."
Code Block |
---|
>> exit
finish.m about to lcaClear
Entering labca finalizer
--------------------------------------------------------------------------------
Segmentation violation detected at 2023-03-07 23:18:49 -0800
--------------------------------------------------------------------------------
Configuration:
Crash Decoding : Disabled - No sandbox or build area path
Crash Mode : continue (default)
Default Encoding : UTF-8
Deployed : false
GNU C Library : 2.17 stable
Graphics Driver : Uninitialized software
Graphics card 1 : 0x102b ( 0x102b ) 0x534 Version 0.0.0.0 (0-0-0)
Java Version : Java 1.8.0_202-b08 with Oracle Corporation Java HotSpot(TM) 64-Bit Server VM mixed mode
MATLAB Architecture : glnxa64
MATLAB Entitlement ID : 6397849
MATLAB Root : /afs/slac.stanford.edu/g/lcls/vol9/package/matlab/2022b
MATLAB Version : 9.13.0.2166757 (R2022b) Update 4
OpenGL : software
Operating System : "Red Hat Enterprise Linux Server release 7.9 (Maipo)"
Process ID : 29718
Processor ID : x86 Family 6 Model 63 Stepping 2, GenuineIntel
Session Key : 455c04fb-90e4-445d-a778-ba3106ff69bd
Static TLS mitigation : Enabled: Full
Window System : The X.Org Foundation (11906000), display localhost:25.0
Fault Count: 1
Abnormal termination:
Segmentation violation
Current Thread: 'MCR 0 interpret' id 140077373851392
Register State (from fault):
RAX = 00007f6691d5e7a0 RBX = 00007f64b9b92e50
RCX = 00007f64a80939b0 RDX = 00007f64b9c85df0
RSP = 00007f664e1bf690 RBP = 0000000000000000
RSI = 00007f64b9b92e50 RDI = 0000000000000000
R8 = 0000000000000000 R9 = 00007f64b9ba2870
R10 = 00007f664e1bf120 R11 = 00007f6691b39570
R12 = 00007f64b9ba83c0 R13 = 00007f64b9ba83c0
R14 = 00007f64b9ba8378 R15 = 0000000000000000
RIP = 00007f6691b27f24 EFL = 0000000000010206
CS = 0033 FS = 0000 GS = 0000
Stack Trace (from fault):
[ 0] 0x00007f6691b27f24 /afs/slac/g/lcls/epics/base/R7.0.3.1-1.0/lib/rhel7-x86_64/libCom.so+00249636 _ZN10epicsMutex4lockEv+00000004
[ 1] 0x00007f64b9ba81b0 <unknown-module>+00000000
** This crash report has been saved to disk as /u/gu/ktkim/matlab_crash_dump.29718-1 **
MATLAB is exiting because of fatal error |