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.
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.
Most helpful comment
The
cudafunction returns a new meshes object without modifying the original. You might wantmesh=mesh.cuda().I think the following should be normal and should work
or
Best not to expect to use
utilswithinpytorch3d.