Pytorch3d: Can't use cuda

Created on 11 Mar 2020  路  5Comments  路  Source: facebookresearch/pytorch3d

I run the following code in ubuntu anaconda virtual environment.

import pytorch3d
import torch
import pytorch3d.structures as structures
import pytorch3d.utils as utils


print(torch.cuda.is_available())
utils.ico_sphere()
mesh.cuda()
print(mesh.device)

Here is the output:

cpu

The expected device is cuda but it turns out to be cpu.
Also, if I only import pytorch3d without import pytorch3d.utils as utils, then it will give an AttributeError: module 'pytorch3d' has no attribute 'utils'. The same error for other pytorch3d modules.

question

Most helpful comment

The cuda function returns a new meshes object without modifying the original. You might want mesh=mesh.cuda().

I think the following should be normal and should work

from pytorch3d.utils import ico_sphere
mesh = ico_sphere(...)

or

import pytorch3d.utils
mesh = pytorch3d.utils.ico_sphere(...)

Best not to expect to use utils within pytorch3d.

All 5 comments

Actually if I use device = 'cuda', it will still go wrong. I install pytorch3d offline. Maybe there is some path issues but I'm not familiar with conda.

It seems you have two separate errors. The error for 'pytorch3d' has no attribute 'utils'. suggests that pytorch3d was not installed properly. Are you installing via local clone?

I download the file from anaconda website and install with conda install --offline path.

The cuda function returns a new meshes object without modifying the original. You might want mesh=mesh.cuda().

I think the following should be normal and should work

from pytorch3d.utils import ico_sphere
mesh = ico_sphere(...)

or

import pytorch3d.utils
mesh = pytorch3d.utils.ico_sphere(...)

Best not to expect to use utils within pytorch3d.

Oh, I see. Thank you for your timely reply.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

TSKongLingwei picture TSKongLingwei  路  3Comments

ruslanvasylev picture ruslanvasylev  路  3Comments

zhjscut picture zhjscut  路  3Comments

elcronos picture elcronos  路  3Comments

farhanrw picture farhanrw  路  3Comments