Successfully resolved AttributeError: module 'torch' has no attribute 'sparse_csc'

Problem Description

PyTorchI torch-geometrichad AttributeError: module 'torch' has no attribute 'sparse_csc'this using and .

AttributeError: module 'torch' has no attribute 'sparse_csc'

Cause Analysis:

At first I thought it torchwas a version problem, but later I tried a lot of versions but torch-geometricit didn't work. I checked the version later and found that it was a problem torch-geometricwith .

When I call torch.sparse_csc()the function , the Python interpreter torchlooks for sparse_cscthe attribute . If the attribute cannot be found, the Python interpreter throws AttributeErroran exception , telling you that the attribute does not exist.

torch-geometricImplementation and support for sparse_cscthe attribute , so you can use the attribute without AttributeErrorerrors in the new version.

solution:

The version I torch-geometricused was the latest version 2.3.0, and then I changed it to 2.1.0and . You can take a look at my dependencies, as follows:

torch              1.11.0+cu113
torch-cluster      1.6.0
torch-geometric    2.1.0
torch-scatter      2.0.9
torch-sparse       0.6.13
torch-spline-conv  1.2.1
torchvision        0.12.0+cu113

You can install according to my environment.

Guess you like

Origin blog.csdn.net/m0_47256162/article/details/130649406