2

A Ubuntu 24.04 machine uses an old Nvidia GPU that uses nvidia-driver-470.

$ nvidia-smi   
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.256.02   Driver Version: 470.256.02   CUDA Version: 11.4     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  Off  | 00000000:65:00.0  On |                  N/A |
| 31%   43C    P8    28W / 250W |    479MiB /  6075MiB |     27%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

Accordingly, CUDA Version: 11.4 is needed. However, Ubuntu 24.04 is packaged to install CUDA 12 when sudo apt purge nvidia-cuda-toolkit is executed. Also, nvidia website did not provide CUDA 11.4 for Ubuntu 24.04 cuda11.4.

Can I install CUDA 11.4 in Ubuntu 24.04? If so, how?

Update:

Following @ubfan1's answer, in my download folder, I did the following but encountered a difficulty. The gcc ver.13.3 in Ubuntu 24.04 is not suitable for compiling cuda11.4. This answer states that gcc 11 is suitable for CUDA 11.4.1 which was downloaded. How do I install that gcc 11 into /usr/local/cuda11.4/bin?

$ sudo chown user1 /usr/local/
$ wget https://developer.download.nvidia.com/compute/cuda/11.4.1/local_installers/cuda_11.4.1_470.57.02_linux.run
$ chmod +x cuda_11.4.1_470.57.02_linux.run
$ ./cuda_11.4.1_470.57.02_linux.run
  Failed to verify gcc version. See log at /tmp/cuda-installer.log for details.
$ cat /tmp/cuda-installer.log
[INFO]: Driver installation detected by command: apt list --installed | grep -e nvidia-driver-[0-9][0-9][0-9] -e nvidia-[0-9][0-9][0-9]
[INFO]: Cleaning up window
[INFO]: Complete
[INFO]: Checking compiler version...
[INFO]: gcc location: /usr/bin/gcc

[INFO]: gcc version: gcc version 13.3.0 (Ubuntu 13.3.0-6ubuntu2~24.04)

[ERROR]: unsupported compiler version: 13.3.0. Use --override to override this check.

Update 1: I did the following:

Step 1: Install gcc-11 and g++-11

$ sudo nala install gcc-11 g++-11
$ dpkg -l | grep g++-11
ii  g++-11                                         11.4.0-9ubuntu1                          amd64        GNU C++ compiler
$ dpkg -l | grep gcc-11
ii  gcc-11                                         11.4.0-9ubuntu1                          amd64        GNU C compiler
ii  gcc-11-base:amd64                              11.4.0-9ubuntu1                          amd64        GCC, the GNU Compiler Collection (base package)
ii  libgcc-11-dev:amd64                            11.4.0-9ubuntu1                          amd64        GCC support library (development files)

Step 2: Create folders bin and lib in /usr/local/cuda-11.4/ and create links related to gcc-11 and g++-11 into /usr/local/cuda-11.4/bin.

$ mkdir /usr/local/cuda-11.4/bin
$ mkdir /usr/local/cuda-11.4/lib
$ ls -la /usr/bin | grep gcc
-rwxr-xr-x  1 root root         428 Nov 18  2020 c89-gcc
-rwxr-xr-x  1 root root         454 Nov 18  2020 c99-gcc
lrwxrwxrwx  1 root root          23 Mar 31  2024 gcc-10 -> x86_64-linux-gnu-gcc-10
lrwxrwxrwx  1 root root          23 Apr 12  2024 gcc-11 -> x86_64-linux-gnu-gcc-11
lrwxrwxrwx  1 root root          23 Apr  3  2024 gcc-12 -> x86_64-linux-gnu-gcc-12
lrwxrwxrwx  1 root root          23 Sep  4 22:44 gcc-13 -> x86_64-linux-gnu-gcc-13
lrwxrwxrwx  1 root root           9 Jan 31  2024 gcc-ar -> gcc-ar-13
lrwxrwxrwx  1 root root          26 Mar 31  2024 gcc-ar-10 -> x86_64-linux-gnu-gcc-ar-10
lrwxrwxrwx  1 root root          26 Apr 12  2024 gcc-ar-11 -> x86_64-linux-gnu-gcc-ar-11
lrwxrwxrwx  1 root root          26 Apr  3  2024 gcc-ar-12 -> x86_64-linux-gnu-gcc-ar-12
lrwxrwxrwx  1 root root          26 Sep  4 22:44 gcc-ar-13 -> x86_64-linux-gnu-gcc-ar-13
lrwxrwxrwx  1 root root           9 Jan 31  2024 gcc-nm -> gcc-nm-13
lrwxrwxrwx  1 root root          26 Mar 31  2024 gcc-nm-10 -> x86_64-linux-gnu-gcc-nm-10
lrwxrwxrwx  1 root root          26 Apr 12  2024 gcc-nm-11 -> x86_64-linux-gnu-gcc-nm-11
lrwxrwxrwx  1 root root          26 Apr  3  2024 gcc-nm-12 -> x86_64-linux-gnu-gcc-nm-12
lrwxrwxrwx  1 root root          26 Sep  4 22:44 gcc-nm-13 -> x86_64-linux-gnu-gcc-nm-13
lrwxrwxrwx  1 root root          13 Jan 31  2024 gcc-ranlib -> gcc-ranlib-13
lrwxrwxrwx  1 root root          30 Mar 31  2024 gcc-ranlib-10 -> x86_64-linux-gnu-gcc-ranlib-10
lrwxrwxrwx  1 root root          30 Apr 12  2024 gcc-ranlib-11 -> x86_64-linux-gnu-gcc-ranlib-11
lrwxrwxrwx  1 root root          30 Apr  3  2024 gcc-ranlib-12 -> x86_64-linux-gnu-gcc-ranlib-12
lrwxrwxrwx  1 root root          30 Sep  4 22:44 gcc-ranlib-13 -> x86_64-linux-gnu-gcc-ranlib-13
lrwxrwxrwx  1 root root          23 Jan 31  2024 x86_64-linux-gnu-gcc -> x86_64-linux-gnu-gcc-13
-rwxr-xr-x  1 root root      887536 Mar 31  2024 x86_64-linux-gnu-gcc-10
-rwxr-xr-x  1 root root      928616 Apr 12  2024 x86_64-linux-gnu-gcc-11
-rwxr-xr-x  1 root root     1391912 Apr  3  2024 x86_64-linux-gnu-gcc-12
-rwxr-xr-x  1 root root     1023032 Sep  4 22:44 x86_64-linux-gnu-gcc-13
lrwxrwxrwx  1 root root          26 Jan 31  2024 x86_64-linux-gnu-gcc-ar -> x86_64-linux-gnu-gcc-ar-13
-rwxr-xr-x  1 root root       27152 Mar 31  2024 x86_64-linux-gnu-gcc-ar-10
-rwxr-xr-x  1 root root       27152 Apr 12  2024 x86_64-linux-gnu-gcc-ar-11
-rwxr-xr-x  1 root root       35448 Apr  3  2024 x86_64-linux-gnu-gcc-ar-12
-rwxr-xr-x  1 root root       27216 Sep  4 22:44 x86_64-linux-gnu-gcc-ar-13
lrwxrwxrwx  1 root root          26 Jan 31  2024 x86_64-linux-gnu-gcc-nm -> x86_64-linux-gnu-gcc-nm-13
-rwxr-xr-x  1 root root       27152 Mar 31  2024 x86_64-linux-gnu-gcc-nm-10
-rwxr-xr-x  1 root root       27152 Apr 12  2024 x86_64-linux-gnu-gcc-nm-11
-rwxr-xr-x  1 root root       35448 Apr  3  2024 x86_64-linux-gnu-gcc-nm-12
-rwxr-xr-x  1 root root       27216 Sep  4 22:44 x86_64-linux-gnu-gcc-nm-13
lrwxrwxrwx  1 root root          30 Jan 31  2024 x86_64-linux-gnu-gcc-ranlib -> x86_64-linux-gnu-gcc-ranlib-13
-rwxr-xr-x  1 root root       27152 Mar 31  2024 x86_64-linux-gnu-gcc-ranlib-10
-rwxr-xr-x  1 root root       27152 Apr 12  2024 x86_64-linux-gnu-gcc-ranlib-11
-rwxr-xr-x  1 root root       35448 Apr  3  2024 x86_64-linux-gnu-gcc-ranlib-12
-rwxr-xr-x  1 root root       27216 Sep  4 22:44 x86_64-linux-gnu-gcc-ranlib-13
$ ln -s /usr/bin/gcc-11 /usr/local/cuda-11.4/bin/gcc
$ ln -s /usr/bin/g++-11 /usr/local/cuda-11.4/bin/g++
$ ln -s /usr/bin/gcc-ar-11 /usr/local/cuda-11.4/bin/gcc-ar
$ ln -s /usr/bin/gcc-nm-11 /usr/local/cuda-11.4/bin/gcc-nm
$ ln -s /usr/bin/gcc-ranlib-11 /usr/local/cuda-11.4/bin/gcc-ranlib
$ ln -s /usr/bin/x86_64-linux-gnu-gcc-11 /usr/local/cuda-11.4/bin/x86_64-linux-gnu-gcc

Step 3: Install CUDA 11.4 toolkit without installing graphic driver

$ sh cuda_11.4.1_470.57.02_linux.run --toolkit --toolkitpath="/usr/local/cuda-11.4" --samples --librarypath="/usr/local/cuda-11.4/lib"
===========
= Summary =
===========

Driver: Not Selected Toolkit: Installed in /usr/local/cuda-11.4/ Samples: Installed in /home/user1/

Please make sure that

  • PATH includes /usr/local/cuda-11.4/bin
  • LD_LIBRARY_PATH includes /usr/local/cuda-11.4/lib64, or, add /usr/local/cuda-11.4/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-11.4/bin ***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 470.00 is required for CUDA 11.4 functionality to work. To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file: sudo <CudaInstaller>.run --silent --driver

Logfile is /tmp/cuda-installer.log $ echo 'export PATH=/usr/local/cuda-11.4/bin:$PATH' >> ~/.bashrc $ echo 'export LD_LIBRARY_PATH=/usr/local/cuda-11.4/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc $ source ~/.bashrc $ sudo ldconfig $ nvcc --version nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2021 NVIDIA Corporation Built on Wed_Jul_14_19:41:19_PDT_2021 Cuda compilation tools, release 11.4, V11.4.100 Build cuda_11.4.r11.4/compiler.30188945_0

Step 4: Revert ownership of /usr/local to root.

$ sudo chown root /usr/local/  

However, I can't seem to compile the samples provided in $HOME/NVIDIA_CUDA-11.4_Sample.

$ cd ~/NVIDIA_CUDA-11.4_Sample
$ ls
0_Simple  1_Utilities  2_Graphics  3_Imaging  4_Finance  5_Simulations  6_Advanced  7_CUDALibraries  common  EULA.txt  Makefile
$ make
make[1]: Entering directory '/home/user1/NVIDIA_CUDA-11.4_Samples/0_Simple/cudaNvSci'
>>> WARNING - libnvscibuf.so not found, please install libnvscibuf.so <<<
>>> WARNING - libnvscisync.so not found, please install libnvscisync.so <<<
>>> WARNING - nvscibuf.h not found, please install nvscibuf.h <<<
>>> WARNING - nvscisync.h not found, please install nvscisync.h <<<
>>> GCC Version is greater or equal to 4.7.0 <<<
[@] /usr/local/cuda/bin/nvcc -ccbin g++ -I../../common/inc -m64 --std=c++11 --threads 0 --std=c++11 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_86,code=compute_86 -o cudaNvSci.o -c cudaNvSci.cpp
[@] /usr/local/cuda/bin/nvcc -ccbin g++ -I../../common/inc -m64 --std=c++11 --threads 0 --std=c++11 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_86,code=compute_86 -o imageKernels.o -c imageKernels.cu
[@] /usr/local/cuda/bin/nvcc -ccbin g++ -I../../common/inc -m64 --std=c++11 --threads 0 --std=c++11 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_86,code=compute_86 -o main.o -c main.cpp
[@] /usr/local/cuda/bin/nvcc -ccbin g++ -m64 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_86,code=compute_86 -o cudaNvSci cudaNvSci.o imageKernels.o main.o -L/usr/local/cuda/lib64/stubs -lcuda -lnvscibuf -lnvscisync
[@] mkdir -p ../../bin/x86_64/linux/release
[@] cp cudaNvSci ../../bin/x86_64/linux/release
make[1]: Leaving directory '/home/user1/NVIDIA_CUDA-11.4_Samples/0_Simple/cudaNvSci'
make[1]: Entering directory '/home/user1/NVIDIA_CUDA-11.4_Samples/0_Simple/cppIntegration'
/usr/local/cuda/bin/nvcc -ccbin g++ -I../../common/inc -m64 --threads 0 --std=c++11 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_86,code=compute_86 -o cppIntegration.o -c cppIntegration.cu
nvcc warning : The 'compute_35', 'compute_37', 'compute_50', 'sm_35', 'sm_37' and 'sm_50' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
/usr/include/stdio.h(195): error: attribute "__malloc__" does not take arguments

/usr/include/stdio.h(207): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(229): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(266): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(291): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(300): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(309): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(315): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(321): error: attribute "malloc" does not take arguments

/usr/include/stdio.h(904): error: attribute "malloc" does not take arguments

/usr/include/stdlib.h(698): error: attribute "malloc" does not take arguments

/usr/include/stdlib.h(702): error: attribute "malloc" does not take arguments

/usr/include/stdlib.h(931): error: attribute "malloc" does not take arguments

/usr/include/wchar.h(179): error: attribute "malloc" does not take arguments

/usr/include/wchar.h(719): error: attribute "malloc" does not take arguments

15 errors detected in the compilation of "cppIntegration.cu". make[1]: *** [Makefile:322: cppIntegration.o] Error 255 make[1]: Leaving directory '/home/user1/NVIDIA_CUDA-11.4_Samples/0_Simple/cppIntegration' make: *** [Makefile:51: 0_Simple/cppIntegration/Makefile.ph_build] Error 2

How do I resolve the above compile errors?

Update 2:

$ sudo find /usr -name stdio.h
/usr/local/cuda-11.4/targets/x86_64-linux/include/cuda/std/detail/libcxx/include/stdio.h
/usr/include/c++/11/tr1/stdio.h
/usr/include/c++/10/tr1/stdio.h
/usr/include/c++/13/tr1/stdio.h
/usr/include/x86_64-linux-gnu/bits/stdio.h
/usr/include/stdio.h
$ sudo find /usr -name stdlib.h
/usr/local/cuda-11.4/targets/x86_64-linux/include/cuda/std/detail/libcxx/include/stdlib.h
/usr/include/c++/11/tr1/stdlib.h
/usr/include/c++/11/stdlib.h
/usr/include/c++/10/tr1/stdlib.h
/usr/include/c++/10/stdlib.h
/usr/include/c++/13/tr1/stdlib.h
/usr/include/c++/13/stdlib.h
/usr/include/x86_64-linux-gnu/bits/stdlib.h
/usr/include/stdlib.h

Should the stdio.h and stdlib.h files in /usr/local/cuda-11.4/targets/x86_64-linux/include/cuda/std/detail/libcxx/include/ instead of those in /usr/include/?

Also:

$ ls -la /usr/local/cuda/bin
total 85324
drwxrwxr-x  3 user1 user1     4096 Dec 27 00:32 .
drwxrwxr-x 18 user1 user1     4096 Dec 27 00:32 ..
-rwxr-xr-x  1 user1 user1    80608 Dec 27 00:31 bin2c
lrwxrwxrwx  1 user1 user1        4 Dec 27 00:31 computeprof -> nvvp
-r-xr-xr-x  1 user1 user1      115 Dec 27 00:31 compute-sanitizer
drwxrwxr-x  2 user1 user1     4096 Dec 27 00:31 crt
-rwxr-xr-x  1 user1 user1  5533504 Dec 27 00:31 cudafe++
-rwxr-xr-x  1 user1 user1 13510432 Dec 27 00:31 cuda-gdb
-rwxr-xr-x  1 user1 user1   778072 Dec 27 00:31 cuda-gdbserver
-rwxr-xr-x  1 user1 user1      800 Dec 27 00:32 cuda-install-samples-11.4.sh
-rwxr-xr-x  1 user1 user1   356336 Dec 27 00:31 cuda-memcheck
-rwxr-xr-x  1 user1 user1   987845 Dec 27 00:32 cuda-uninstaller
-rwxr-xr-x  1 user1 user1    75880 Dec 27 00:31 cu++filt
-rwxr-xr-x  1 user1 user1   236880 Dec 27 00:31 cuobjdump
-rwxr-xr-x  1 user1 user1   273504 Dec 27 00:31 fatbinary
lrwxrwxrwx  1 user1 user1       15 Dec 27 00:17 g++ -> /usr/bin/g++-11
lrwxrwxrwx  1 user1 user1       15 Dec 27 00:16 gcc -> /usr/bin/gcc-11
lrwxrwxrwx  1 user1 user1       18 Dec 27 00:20 gcc-ar -> /usr/bin/gcc-ar-11
lrwxrwxrwx  1 user1 user1       18 Dec 27 00:20 gcc-nm -> /usr/bin/gcc-nm-11
lrwxrwxrwx  1 user1 user1       22 Dec 27 00:21 gcc-ranlib -> /usr/bin/gcc-ranlib-11
-r-xr-xr-x  1 user1 user1     2974 Dec 27 00:31 ncu
-r-xr-xr-x  1 user1 user1     2577 Dec 27 00:31 ncu-ui
-rwxr-xr-x  1 user1 user1     1580 Dec 27 00:31 nsight_ee_plugins_manage.sh
-r-xr-xr-x  1 user1 user1       82 Dec 27 00:31 nsight-sys
-r-xr-xr-x  1 user1 user1      746 Dec 27 00:31 nsys
-r-xr-xr-x  1 user1 user1      104 Dec 27 00:31 nsys-exporter
-r-xr-xr-x  1 user1 user1      739 Dec 27 00:31 nsys-ui
-rwxr-xr-x  1 user1 user1  5862824 Dec 27 00:31 nvcc
-rw-r--r--  1 user1 user1      417 Dec 27 00:31 nvcc.profile
-rwxr-xr-x  1 user1 user1 33717208 Dec 27 00:31 nvdisasm
-rwxr-xr-x  1 user1 user1 10169920 Dec 27 00:31 nvlink
lrwxrwxrwx  1 user1 user1        6 Dec 27 00:31 nv-nsight-cu -> ncu-ui
lrwxrwxrwx  1 user1 user1        3 Dec 27 00:31 nv-nsight-cu-cli -> ncu
-rwxr-xr-x  1 user1 user1  5664800 Dec 27 00:31 nvprof
-rwxr-xr-x  1 user1 user1   101296 Dec 27 00:31 nvprune
-rwxr-xr-x  1 user1 user1      285 Dec 27 00:31 nvvp
-rwxr-xr-x  1 user1 user1  9943440 Dec 27 00:31 ptxas
lrwxrwxrwx  1 user1 user1       32 Dec 27 00:23 x86_64-linux-gnu-gcc -> /usr/bin/x86_64-linux-gnu-gcc-11
Sun Bear
  • 3,014

1 Answers1

2

Answer 1077061 is the best place for explicit instructions so this is for the problem of installing an older release, with out-of-date libraries and drivers. Nvidia offers two install mechanisms, a deb package and a run script. The goal is to get all of the CUDA release into its own directory, so system areas are not polluted with old libraries. unpacking the deb file used to be an easy way to do this, but later releases made this harder, so the .run script example is used here.

The .run scripts are for a CUDA release, get the one for the latest OS offered (20.04 in your case). This script will try to make a directory in /usr/local, even if it doesn't need to (i.e. you make it yourself owned by you). Rather than try to edit a fix into a 1.5GB script, I took temporary ownership of /usr/local so I could run the script without sudo. The script may attempt writing something in /usr/share, but I never bothered taking ownership of that -- I didn't care about whatever (icons?) were not installed.

./cuda-release-xxx.run and accept the license.

Then a text menu will allow you to tailor the installation. Uncheck the driver, you should already have a running Nvidia driver from the standard repos on your system that gets updates when needed. Now go to the options, and you can change the install location for libraries and executables. Change them to /usr/local/cuda-11.4/lib64 and /usr/local/cuda-11.4/bin (or your cuda release directory that the script will create). This keeps old stuff out of system areas. Another benefit is that if an old compiler is needed, just add it to the cuda bin area.


In your case of 24.04, while the default compiler is gcc-13, the older gcc-11 is still available from the standard repositories. Just install it, it will not interfere with the default compiler. Do not change any links like /bin/gcc. Just add links in your /usr/local/cuda-11.4/bin (or your install location's bin for gcc (and ar, nm, and ranlib) to the normal system location in /usr/bin for the "11" versions (gcc-ar-11, gcc-nm-11, gcc-ranlib-11). e.g.:

ln -s /usr/bin/gcc-11 /usr/local/cuda-11.4/bin/gcc
ln -s /usr/bin/gcc-ar-11 /usr/local/cuda-11.4/bin/ar
ln -s /usr/bin/gcc-nm-11 /usr/local/cuda-11.4/bin/nm
ln -s /usr/bin/gcc-ranlib-11 /usr/local/cuda-11.4/bin/ranlib
ln -s /usr/bin/g++-11 /usr/local/cuda-11.4/bin/g++

Or use the full names like /usr/bin/x86_64-linux-gnu-gcc-ar-13 if you prefer, but the gcc-ar-11 links should work as targets, and may be less confusing.

If the old compiler is offered as a standard system install, just install it and add links to it from the cuda bin area. If the required compiler is not offered in the standard repos, you will need to locate a copy to install to the cuda bin area.

After the install completes, you may move the /usr/local/cuda-11.4 directory to wherever you want, and change ownership of /usr/local back to root.


Note that the sample code Makefiles will default a CUDA_PATH to /usr/local/cuda. If your install is to /usr/local/cuda-11.4, you can make a link /usr/local/cuda to that location. If you'd moved the install somewhere else, define and export CUDA_PATH in your .profile for that location.


Change the PATH and LD_LIBRARY_PATH as recommended, putting the cuda bin (into PATH) and the cuda lib64 (into LD_LIBRARY_PATH) at the beginning, so the old compiler/libraries get picked up first. Use a project specific script to change PATH and LD_LIBRARY_PATH if you don't want them changed every time you login (if you'd added them to your .profile).

I have not had problems running old CUDA versions on much later systems, and several cuda releases may be installed into a system in their own directory (with a project specific PATH modifications). Treat CUDA as an app, it doesn't need to modify any system files or have special drivers, and sprinkling old files into system areas is a sure way to confuse updates, so this method avoids that.

I have noticed that running the samples (under xorg), I usually need to reverse the source/sink providers on my hybrid laptop. From a terminal, set the variables on the command line before the "program to run" for a one time invocation:

__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia <progtorun>

You may put these variables in a script or in your .profile and export them if you find that more convenient. Note that under xorg, you can run

 xrandr --listproviders

and see the source/sink setup. Hybrid laptops sometimes get things reversed, and need explicit setting of source/sink that works with their hardware.

ubfan1
  • 19,049