PyTorch causing problems with CUDA on Colab

Onur_Ozbek: <p>I am trying to implement a face extraction model using Colab. For that, I am removing Colab’s CUDA to install 10-2 and I’m also installing Anaconda. This is the entirety:</p>
<pre><code class="lang-auto">import condacolab, torch, sys, skimage, matplotlib, imageio, plotly, cv2, black, flake8, facenet_pytorch

from google.colab import drive

drive.mount('/content/gdrive')
!git clone https://github.com/Chinmayrane16/ReconNet-PyTorch
!cp /content/gdrive/MyDrive/headsegmentation_final2.zip /content/gdrive/MyDrive/3DMM-Fitting-Pytorch.zip /content/
!cp /content/gdrive/MyDrive/Anaconda3.sh .
!unzip -qq /content/3DMM-Fitting-Pytorch.zip
!unzip -qq /content/ReconNet-PyTorch/images/all\ images/BSDS200.zip

!mv /content/ReconNet-PyTorch/*.py /content/
!mkdir results

!apt-get update -y
!apt-get --purge remove "*cublas*" "cuda*" "nsight*" 

!wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin
!mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600
!wget https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
!dpkg -i cuda-repo-ubuntu1804-10-2-local-10.2.89-440.33.01_1.0-1_amd64.deb
!apt-key add /var/cuda-repo-10-2-local-10.2.89-440.33.01/7fa2af80.pub
!apt-get install cuda-10-2 libtorch -y
!apt autoremove -y

!chmod 777 Anaconda3.sh
!./Anaconda3.sh

condacolab.install()

!conda update conda
!conda create -n pytorch3d python=3.9
!conda activate pytorch3d
!conda install -c pytorch pytorch=1.9.1 torchvision cudatoolkit=10.2
!conda install -c fvcore -c iopath -c conda-forge fvcore iopath

!conda install -c bottler nvidiacub

!conda install jupyter
!conda install pytorch3d -c pytorch3d

pyt_version_str = torch.__version__.split("+")[0].replace(".", "")
version_str="".join([f"py3{sys.version_info.minor}_cu", torch.version.cuda.replace(".",""), f"_pyt{pyt_version_str}"])
!pip3 install --no-index --no-cache-dir pytorch3d -f https://dl.fbaipublicfiles.com/pytorch3d/packaging/wheels/{version_str}/download.html
!export CUB_HOME=$PWD/cub-1.10.0

!pip3 install "git+https://github.com/facebookresearch/pytorch3d.git@stable"

!rm -rf sample_data/ *.sh *.run
</code></pre>
<p>And this is the error I get when I try to run a Python file…</p>
<pre><code class="lang-auto">/usr/local/lib/python3.7/site-packages/torchvision/io/image.py:11: UserWarning: Failed to load image Python extension: /usr/local/lib/python3.7/site-packages/torchvision/image.so: undefined symbol: _ZNK2at10TensorBase21__dispatch_contiguousEN3c1012MemoryFormatE
  warn(f"Failed to load image Python extension: {e}")
Traceback (most recent call last):
  File "fit_single_img.py", line 2, in &lt;module&gt;
    from core.options import ImageFittingOptions
  File "/content/3DMM-Fitting-Pytorch/core/__init__.py", line 1, in &lt;module&gt;
    from core.BFM09Model import BFM09ReconModel
  File "/content/3DMM-Fitting-Pytorch/core/BFM09Model.py", line 5, in &lt;module&gt;
    from core.BaseModel import BaseReconModel
  File "/content/3DMM-Fitting-Pytorch/core/BaseModel.py", line 5, in &lt;module&gt;
    from pytorch3d.renderer import (
  File "/usr/local/lib/python3.7/site-packages/pytorch3d/renderer/__init__.py", line 7, in &lt;module&gt;
    from .blending import (
  File "/usr/local/lib/python3.7/site-packages/pytorch3d/renderer/blending.py", line 11, in &lt;module&gt;
    from pytorch3d import _C
ImportError: libc10_cuda.so: cannot open shared object file: No such file or directory
</code></pre>
<p>Where am I going wrong?</p>