Foreword
On Github, the environment required for some earlier code may be CUDA8.0. For a novice, normal thinking will choose the most cash version for environment configuration. Here is a brief introduction how to use [GPU] (https://cloud.tencent.com/product/gpu?from=10680) When performing calculations, CUDA8.0 and CUDA9.0 coexist.
1、 Check before installation
Run the following command to check the current CUDA version of your computer
nvcc --version
My own computer displays as follows: (CUDA9.0 currently installed in my computer)
2、 Download the appropriate CUDA8.0 version
When choosing CUDA8.0 version, you must choose according to your own computer system and corresponding environment, download link
In the corresponding download link interface, proceed as follows: (My own Ubuntu server, 16.04, here we choose the runfile installation form)
Tips: Since mine is on the server side, if someone is also installing on the server side, remember to upload the downloaded file to the server side first.
3、 Perform the appropriate installation
In the corresponding folder you downloaded, perform the following operations:
cd CUDA8 #Go to the folder containing the above downloaded file
sudo chmod 777 cuda_8.0.61_375.26_linux.run ##Give files certain permissions
. /cuda_8.0.61_375.26_linux.run ##start installation
After running the installation instructions, Nvidia's introduction document will appear, such as the following:
The most important point is that the introduction document requires some operations from you, otherwise the installation process cannot continue, there are two ways to skip the introduction document
After you skip the introduction document, there will be some options that you need to choose: (The input corresponding to each step is marked with a red circle in the figure below. Here is an explanation: Driver must select n, because You have installed a driver that supports CUDA9.0 before, so you don’t need to install a new one)
4、 Make the corresponding environment configuration
Enter the following installation path, open the bashrc file, and then locate to the lowest end (see the figure below for the operation process)
As you can see, on my computer side, the imported paths are all cuda9.0:
Here, if we want to use the CUDA8.0 just installed, we only need to do the following:
Replace the corresponding cuda-9.0 with cuda-8.0, as shown in the figure below (exit after saving)
Then in the terminal, execute the following command to source:
source ~/.bashrc
Then you can perform the corresponding verification: (As shown in the figure below, you can see that the CUDA8.0 version is installed successfully)
5. Switch between multiple cuda versions
The above is only the case when you want to use one of them. If you often want to switch between versions, the following method is recommended:
Change all cuda-related paths under ~/.bashrc to /usr/local/cuda/ instead of /usr/local/cuda-8.0/ or /usr/local/cuda-9.0/.
# When switching cuda version
rm -rf /usr/local/cuda#Delete the soft link created before
sudo ln -s /usr/local/cuda-8.0/usr/local/cuda
nvcc --version #View the current cuda version
nvcc:NVIDIA(R) Cuda compiler driver
Copyright(c)2005-2016 NVIDIA Corporation
Built on Mon_Jan_23_12:24:11_CST_2017
Cuda compilation tools, release 8.0, V8.0.62
# cuda8.0 Switch to cuda9.0
rm -rf /usr/local/cuda
sudo ln -s /usr/local/cuda-9.0/usr/local/cuda
nvcc --version
The modification method of ~/.bahsrc file is the same as above.
6、 to sum up
The above just talked about how to convert from CUDA9.0 to CUDA8.0. If you want to switch back to CUDA9.0, you only need to perform the opposite process, change the cuda-8.0 in the bashrc file to cuda-9.0, and then source it. , You can.
Recommended Posts