Installation problems with torch, torchvision, models, cuda

I am wondering if anyone else is having problems as I have in installing the various libraries to get the lesson-1 jupyter notebook to run?
For example, when I ran
from fastai.transforms import *

I got the following error: (The ‘^’ sign us under the second quote mark)
File "fastai/", line 24 if pre: load_model(m, f'wgts/{fn}.pth') ^ SyntaxError: invalid syntax

Another example:
When I ran from fastai.conv_learner import *, I got the following error (The ^ sign is also under the second quote.
File "fastai/", line 47 def name(self): return f'{self.f.__name__}_{self.xtra_cut}' ^ SyntaxError: invalid syntax

One more:
When I ran from fastai.model import *, I got the following (The ^ is under the *)
File "fastai/", line 11 for x, *_ in tqdm(gen): ^ SyntaxError: invalid syntax

I have installed pytorch. However, cudu seems to be needed but there doesn’t seem to be an option to install it on the pytorch website.
Any suggestions would be welcome. Thanks in advance.

1 Like

Hi, I got the same error. I can run the code on Crestle but when running on my computer this error pops ups. I am not running on a GPU on my computer.

File “c:\Users\SHIMA\Documents\PillView\Test\pill_test\testing\ticm\fastai\”, line 24
if pre: load_model(m, f’wgts/{fn}.pth’)
SyntaxError: invalid syntax.

Were you able to fix it?

I see a typo changed
if pre: load_model(m, f’wgts/{fn}.pth’)


if pre: load_model(m, f, ‘wgts/{fn}.pth’)

@amritv I found out the problem is because the syntax is for python 3.6, whereas I have python 2.7. Need to either install 3.6 or do things on Crestle or AWS. Thanks for your help, in any case.

1 Like

@willtong thanks! I realized that the hard way. It works fine on Crestle as they have 3.6. Best,

Just jumping on this thread, but I’m having a weird problem today with a jupyter not finding torch. I don’t understand, because it was running fine yesterday. Any thoughts?
If I do python; import torch from a terminal, it’s fine—I only get the error from jupyter.

Hi, I am using paperspace but whenever I am running this part, I am getting a dead kernel!!
from fastai.transforms import *
from fastai.conv_learner import *
from fastai.model import *
from fastai.dataset import *
from fastai.sgdr import *
from fastai.plots import *

any suggestions on what to do?

Also this part is giving me an error that torch not defined.

NameError Traceback (most recent call last)
in ()
----> 1 torch.cuda.is_available()

NameError: name ‘torch’ is not defined

Is this related to the previous part?

1 Like

To source activate fastai before launching jupyter notebook (assumed Python 3.6 is installed) can fix this problem.

i just started using jupyter.
I’m having the same problem…it shows like this
can anyone provide a solution for this
(I’m using nvidia GPU present in my PC itself )

1 Like