在Google Colab上降级CUDA版本较为困难,因为Colab预装了特定版本的CUDA和cuDNN,并且它们会自动更新
!nvcc --version
!apt-get --purge remove cuda nvidia-cuda-toolkit
!dpkg -l | grep cuda- | awk '{print $2}' | xargs -n1 dpkg --purge
!apt-get --purge remove cuda-*
!apt autoremove
!apt-get update
!wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda-repo-ubuntu1804-9-0-local_9.0.176-1_amd64.deb
!dpkg -i cuda-repo-ubuntu1804-9-0-local_9.0.176-1_amd64.deb
!apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub
!apt-get update
!apt-get install cuda-9.0
!wget https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.6.5/prod/9.0_20191031/cudnn-9.0-linux-x64-v7.6.5.32.tgz
!tar -xvf cudnn-9.0-linux-x64-v7.6.5.32.tgz
!cp cuda/include/cudnn.h /usr/local/cuda/include
!cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
!chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
import os
os.environ["CUDA_HOME"] = "/usr/local/cuda"
os.environ["PATH"] = "/usr/local/cuda/bin:" + os.environ["PATH"]
os.environ["LD_LIBRARY_PATH"] = "/usr/local/cuda/lib64:" + os.environ["LD_LIBRARY_PATH"]
!nvcc --version
领取专属 10元无门槛券
手把手带您无忧上云