mathworks / jupyter-matlab-proxy

MATLAB Integration for Jupyter enables you to run MATLAB code in Jupyter Notebooks and other Jupyter environments. You can also open MATLAB in a browser directly from your Jupyter environment to use more MATLAB features.
Other
281 stars 36 forks source link

Link the kernel to a specific version of matlab #74

Closed franklintfcheng closed 11 months ago

franklintfcheng commented 12 months ago

Dear Developers,

I'm currently using jupyter-matlab-proxy on my remote server to run matlab. But there are several version of matlab (e.g., matlab2016, matlab2019a, etc.). Is there anyway to specify the path for the my desired matlab version to run the kernel? Any help is appreciated.

Cheers, Franklin

krisctl commented 12 months ago

Dear @fandycheng,

Thank you for using jupyter-matlab-proxy!

jupyter-matlab-proxy uses another of our package matlab-proxy to manage the selection of desired MATLAB. You can make use of MWI_CUSTOM_MATLAB_ROOT environment variable to point the MATLAB root to a location of your choice before starting jupyter-matlab-proxy. Documentation on how to do that can be found here. In a Linux environment, it would look similar to:

export MWI_CUSTOM_MATLAB_ROOT=/usr/local/MATLAB/R2023a
jupyter lab

Hope that helps!

franklintfcheng commented 12 months ago

Dear @krisctl ,

Thank you for your prompt help! I have tried your suggestion but still failed to get the path correct. Based on the error message, I guess it is because the environmental variable links to the root directory of the Matlab version (but note the direct path), and in my server, all different versions of Matlab were installed on the same root directory, and the name of my Matlab executable is matlabYYYY but notmatlab. I'm pasting the error message for your reference. Many thanks for your great help!

(base) /home/tfchengac$ matlab-proxy-app INFO:MATLABProxyApp:MATLAB root path: /usr/local/bin/matlab2019a exists, continuing to verify its validity... WARNING:MATLABProxyApp:Edit the environment variable MWI_CUSTOM_MATLAB_ROOT to the correct path, and restart matlab-proxy.Unable to locate VersionInfo.xml at /usr/local/bin/matlab2019a INFO:MATLABProxyApp:Using Custom MATLAB Executable: /usr/local/bin/matlab2019a/bin/matlab with Root: /usr/local/bin/matlab2019a WARNING:MATLABProxyApp:Could not determine MATLAB version from MATLAB root path: /usr/local/bin/matlab2019a WARNING:MATLABProxyApp:Set MWI_CUSTOM_MATLAB_ROOT to a valid MATLAB root path

By the way, the latest Matlab version on my server is only matlab2019a, do I need to ask admin to upgrade it in order to use jupyter-matlab-proxy? Thank you again for your kind attention!

Cheers, Franklin

krisctl commented 12 months ago

Hi @fandycheng,

Thank you for sharing the logs with me. On a closer look, it seems that you are setting MWI_CUSTOM_MATLAB_ROOT to /usr/local/bin/matlab2019a which is causing the MATLAB root path check failures. The correct thing to do would be to point to the actual location that is linked to /usr/local/bin/matlab2019a.

There are a few ways to get that location information. One can either run ls -l /usr/local/bin | grep -E "matlab2019a" to figure where the link is pointing to or do something like env MWI_CUSTOM_MATLAB_ROOT=`which matlab2019a | xargs readlink -f` jupyter lab to combine all required steps into one command.

As for your question related to the version of MATLAB supported by jupyter-matlab-proxy, we would need at least a minimum of MATLAB 20b, but recommend getting the latest versions of MATLAB (i.e. 23b).

Best Regards, Krishan

franklintfcheng commented 12 months ago

Hi @krisctl,

Thank you again for your prompt reply! For the Matlab version, I've asked our admin to install the latest one, hopefully I could try that one with the proxy soon.

I have tried your suggested method which matlab2019a | xargs readlink -f and it gives /disk/local_x86_64/bin/matlab2019a. However, I still encountered the same bug using your one-line command. I'm pasting the error message below for your reference.

I checked the path /disk/local_x86_64/bin/ and there is no VersionInfo.xml. And I noticed that the proxy keeps finding the Matlab executable under /disk/local_x86_64/bin/matlab2019a/bin/matlab, but my desired Matlab executable is actually /disk/local_x86_64/bin/matlab2019a.

INFO:MATLABProxyApp:MATLAB root path: /disk/local_x86_64/bin/matlab2019a exists, continuing to verify its validity... WARNING:MATLABProxyApp:Edit the environment variable MWI_CUSTOM_MATLAB_ROOT to the correct path, and restart matlab-proxy.Unable to locate VersionInfo.xml at /disk/local_x86_64/bin/matlab2019a INFO:MATLABProxyApp:Using Custom MATLAB Executable: /disk/local_x86_64/bin/matlab2019a/bin/matlab with Root: /disk/local_x86_64/bin/matlab2019a WARNING:MATLABProxyApp:Could not determine MATLAB version from MATLAB root path: /disk/local_x86_64/bin/matlab2019a WARNING:MATLABProxyApp:Set MWI_CUSTOM_MATLAB_ROOT to a valid MATLAB root path

Any help is much appreciated!

Cheers, Franklin

prabhakk-mw commented 11 months ago

Hi @fandycheng

Thank you for your response.

Could you tell us a little bit more about the executablematlab2019a? How was it created? What does it contain? Is it a script?

Our assumption behind suggesting the which matlab2019a | xargs readlink -f was that matlab2019a was a SYMLINK.

But given that the result is again pointing to /disk/local_x86_64/bin, it makes me believe that perhaps matlab2019a is not a symlink, and is in fact a script that somehow knows how to start MATLAB 2019a.

Please note that MWI_CUSTOM_MATLAB_ROOT needs to point to the folder in which the VersionInfo.xml file is present for a given release of MATLAB.

Can you figure out where that would be?

franklintfcheng commented 11 months ago

Hi @krisctl and @prabhakk-mw ,

Thank you so much for your replies! You are right, the path that I linked was a SYMLINK. Sorry for my mistake. I just figured out the correct path is /usr/local/matlabXXXX. Now I can successfully link the proxy with my Matlab path!

I have asked the admin to help install the latest matlab2023a. But the only issue now is that I have to contact our admin to install Xvfb. Hopefully it will be done soon so that I can check if everything runs perfectly.

Thanks again for your great help!

Cheers, Franklin