Skip to content
vhvkhoa edited this page Aug 19, 2023 · 2 revisions

CUDA-Toolkit Local Installation

Download runtime installer:

  1. Find your desired CUDA-toolkit version here.
  2. Select Linux -> x86_64 -> Ubuntu -> [UnbuntuVersion] -> runfile (local)
  3. Open terminal.
  4. Copy the wget ... command under instructions to download Cuda toolkit installer.

Installation

  1. Instead of running sudo sh cuda... as instructed, remove sudo.
  2. Wait several minutes for the installer to setup and start command prompt.
  3. If it says “Existing package manager installtion of the driver found…”, select Continue.
  4. Type accept when being asked to accept the EULA..
  5. At CUDA Installer page:
    1. Unselect everything except CUDA Toolkit <version>
    2. Go to Options -> Toolkit Options, then:
      1. unselect everything
      2. go to Change Toolkit Install Path
      3. Change toolkit install path to a directory inside your home directory, e.g., /home/<user_name>/cuda-<version>/ if you're installing CUDA 11.8. Also remember the path you use for Step 9.
      4. Press Enter, and select Done, and Done again to go back to CUDA Installer page.
  6. Press Install to start installation.
  7. If the installation is successful, the console will prompt a summary and some instructions to let your terminal use local CUDA toolkit instead of the global version.
  8. Remove log file to avoid installer bug: rm /tmp/cuda-installer.log
  9. To let terminal use your local CUDA Toolkit version, you need to add it to PATH and LIBRARY_PATH environment variables. Use the following command:
echo "export PATH=\"/home/<user_name>/cuda-<version>/bin:\$PATH\"" >> ~/.bashrc
echo "export LD_LIBRARY_PATH=\"/home/<user_name>/cuda-<version>/lib64:\$LD_LIBRARY_PATH\"" >> ~/.bashrc

Why do we need Step 8 ?

This is probably a bug from CUDA Toolkit runfile.

Bug summary: the installation generates a temporal logfile at /tmp/cuda-installer.log. There are 3 scenarios:

  • When another user install CUDA Toolkit with sudo, there is no problem because sudo helps override the file.
  • When the machine is reboot, the file is automatically removed, if another user afterwards, there is also no problem.
  • When another user install CUDA Toolkit without sudo, an error of Log file not open. Segmentation fault (core dumped) will prompt.

Solution: You need to remove the logfile by yourself because only you are allowed to do that (except sudoers): rm /tmp/cuda-installer.log