Unable to edit etc/environment under adminstrator account

I have flash the CUDA 10.2 on the Nano, however, the path is not updated in etc/environment. How can I update the basrch file?

Are you asking how to add the path to find the CUDA content via the bash shell? The answer is different for individual users versus for “everyone”. Because startup scripts and system scripts might have unwanted side-effects by updating for the system as a whole, it would be recommended to update this for the individual user(s). Note that if you wish to make this for all “new users” (should you have more than one user on your Jetson), then this can be done without altering for the system as a whole.

The normal place to edit the “PATH” variable would be in “~/.bashrc”. So examine this:

ls -A .bash*

Note that there are several files related to bash, but it is inside of “~/.bashrc” one would append to the path. As an example, I have appended “/usr/local/bin” to my path, and have also appended “/usr/local/cuda/bin”. My .bashrc line for this:

export PATH=/usr/local/cuda:/usr/local/bin:$PATH

The colon (“:”) is the delimiter.

Incidentally, often library paths are instead updated for the system as a whole. However, if you wanted to add “/usr/local/cuda/lib64” to just the user, then in ~/.bashrc you could add this:

export LD_LIBRAY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

One should be careful though about appending any path to the system library path (versus updating for just one user). A bad path for the system as a whole, in the linker setup, could potentially stop the system from booting. A bad path for an individual user’s library path might stop that one user from logging in. I mention this because the directory should be guaranteed to exist before updating it within the “persistent” environment. An example is that if you add the directory to link to a specific release of CUDA, e.g., “/usr/local/cuda-10.2/lib64”, and then there is an update which changes it to 10.3 (a contrived example), and in which 10.2 is removed, then boot or login could be blocked until repaired. Conversely, if you know “/usr/local/cuda/lib64” will always exist (perhaps as a symbolic link to a specific release), then it is safe to add it to the library linker search path. Also, imagine if the path is from removable media and the media is not present…this would halt boot if part of the system.

Incidentally, if you are going to mess around with LD_LIBRARY_PATH for an individual user, then it might be useful to have a second user added to the system with admin rights prior to working on it. If the change works for that user, excellent…if not, then you still have another user to fix this with via sudo. Should this work for the individual user, it might be considered a quality test before changing this to a system wide edit.

1 Like

Thank linuxdev for sharing the tips.

Thank you for sharing the tips. I am totally new to Linux. I am using MATLAB to detect the CUDA version and I notice that even if cuda-10.2 is in the path, the software cannot detect the cuda version. I need to change to power user on Nano and add cuda in the path then MATLAB can detect the cuda version.

Thank you again for your tips.

It is quite possible that all that is needed is editing those paths in the regular user’s account (the “~” in “~/.bashrc” means the current user’s home directory…try “cd ~” and “ls -l ~/.bashrc”). You wouldn’t need the power user (“sudo”) for that, though you would need it to edit files in “/etc” (such as the file for changing this for all users, but I would advise against changing that without good reason).

There is another problem you might be running into though. Jetsons have an integrated GPU (iGPU) which is wired directly to the memory controller. Most software from third parties expect to find the GPU on the PCIe bus (a discrete GPU, or dGPU). Those which use the “nvidia-smi” program to find CUDA capabilities will always fail on the Jetson since iGPUs don’t use PCIe. Add those file paths in. If the libraries are not found, then it is likely a simple fix, but if (once the libraries are found) the GPU still cannot be found, then it is possible the problem is because it is searching for a dGPU via “nvidia-smi”.

Thank you. I managed to edit.

Now I have issue on how to uninstall CUDA11-0. I have CUDA10, CUDA10-2. To save SD card space, I want to uninstall CUDA11-0

I tried
sudo ./cuda-unistaller but unsuccessful

Most computers have a discrete GPU (dGPU on a PCIe slot). Jetsons have an integrated GPU (iGPU direclty wired to the memory controller). So you can only install the version intended for the Nano. Unfortunately, version 11 is not available for a Nano, and does not have new features added anymore. You’d have to use an Xavier or Orin for that.

Hello, thank you for your response. How can I uninstall or remove version 11 so I can free up the space. Thank you again,

Was it installed via “apt”? If so, what is the package name? If not via package, then the answer is different.

FYI, a way to list all packages with “nv” in their name:
dpkg -l | grep -i 'nv'

This is how I installed it. Please advise.

CUDA Toolkit 11.0 Download | NVIDIA Developer

On Jetson Nano, we support up to CUDA 10.2. Please install it through SDKManager. The latest release for Jetson Nano is Jetpack 4.6.3.

Yes, I installed CUDA 10.2 through SDK Manager. I don’t know why I installed version 11. So now, it is already installed. can I just delete it? or is there proper way to remove it? :-)

We would suggest re-flash the system and re-install SDK Components through SDKManager. This should make a clean environment. If you prefer not to re-flash, may try to list cuda pakages by running $ apt list -a | grep cuda. And run $ sudo apt purge _CUDA_PACKAGE to remove all CUDA 11 packages.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.