How to stop Fastai downgrading Pytorch (to use CPU) on my local machine(ubuntu)?

I am unable to use CUDA (gpu) with my pytorch (locally),
Because Fastai downgrades pytorch to use cpu (instead of GPU).

Following the Live coding 1,2 lectures, after installing Fastai, my pytorch downgraded to use cpu.

So I tried to reinstall Pytorch ( by first removing pytorch : mamba uninstall pytorch
But when i tried this, It removes fastai library + its packages too, because of its dependency with pytorch.
SO after reinstalling pytorch, I had to reinstall fastai using : mamba install -c fastchan fastai
Which again downgrades my pytorch to use cpu.

I am stuck in this loop.
How can i have both - fastai + pytorch (using GPU) locally ??

May just try to install the with CUDA version of PyTorch using Pip. I think Mamba and Anaconda will install/uninstall all dependencies as you are seeing. On my Windows laptop, I was able to use Pip to reinstall PyTorch with CUDA after installing fast.ai.

PyTorch is now using my GPU.

image

Hii, okay here’s what I’ve tried -

  • Run setup-conda.sh , and installed miniconda3 package.
  • Installed mamba - conda install mamba
  • Installed Pytorch - mamba install pytorch.
  • Installed Jupyter lab, ipython etc.
  • Installed Fastai mamba install -c fastchan fastai : which downgrades pytorch to use CPU.

Now if i have to re-install Pytorch (in 2 steps) -

  • Firstly, remove pytorch .
  • then install pytorch again .

How should i do above 2 steps + which package manager to use (to avoid my fastai library, getting removed due to its dependency with pytorch) ?

I tried pip to remove pytorch. (failed)

Hi!

This should work fine for the Windows directly. Using this command in the Powershell.

Hi!

Try to install 2nd instance of the Linux. I understood that You’re anxious about lose your data. Having 2nd Ubuntu will make you freely to experiment. At new instance, that should go by this order:

  1. Install packet manager and python
  2. Check CUDA version that support your GPU (if NVIDIA)
  3. Install Pytorch for Linux and Conda with a command:
#for cuda 12.1
mamba install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia

  1. Install other stuff.

I hope that helps or give U more clues what is going not good.

Regards,

Mike

I already tried the approach you written, after doing rm -rf to everything .
and i checked the CUDA version using nvidia-smi and installed the compatible version with mamba. But then once i install fastai it downgrades pytorch to use cpu …

**pip method not working in linux . So how to remove Pytorch ,without removing fastai. This is the main issue to resolve. So that i could reinstall pytorch.

But still, Thankyou so much for helping.

EDIT:

Sorry! My mistake. The PIP works on the Linux. On Ubuntu, for python 3.xx:

sudo apt install python3-pip
  1. OR
python -m ensurepip --upgrade

To remove Pytorch:

conda remove pytorch torchvision torchaudio pytorch-cuda=12.1

If it doesn’t work, use:

conda remove -f pytorch

Also clear those paths:

/usr/local/lib/python3.X/dist-packages/torch
/usr/local/lib/python3.X/dist-packages/torchvision
/usr/local/lib/python3.X/dist-packages/torchaudio
/usr/local/cuda/lib64/ (pliki CUDA)

Look into ‘settings.ini’ in fastai repo, there’re dependencies:

You’ve got python 3.10 in above-mentioned file “python=3.8” maybe this is cause of a downgrading.

EDIT: Try to fork and edit. Install from the repo with pip3

Good luck!

1 Like

Hi, Thankyou very very much for the help.

I don’t know how it happened, But i removed everything(DL setup) ,
And this time i didn’t installed pytorch first.

  • I just setup miniconda,
  • installed fastai , using mamba (which automatically install some pytorch)
  • Then without removing anything, I again installed pytorch using conda.

This upgraded Pytorch to use GPU. (without making any confilcts/issues)

What I’ve done differently this time - (not installing pytorch initially. but after installing fastai.)

1 Like