Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: expected scalar type Float but found Half #4

Closed
ghost opened this issue Mar 15, 2021 · 3 comments
Closed

RuntimeError: expected scalar type Float but found Half #4

ghost opened this issue Mar 15, 2021 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 15, 2021

When I ran train_net.py, I got an error

RuntimeError: expected scalar type Float but found Half (data_ptr at /home/cy/anaconda3/envs/render/lib/python3.6/s ite-packages/torch/include/ATen/core/TensorMethods.h:6321)
frame #0: c10::Error::Error(c10::SourceLocation, std::string const&) + 0x47 (0x7f32dc94a627 in /home/cy/anaconda3/envs/NHR /lib/python3.6/site-packages/torch/lib/libc10.so)
frame #1: float* at::Tensor::data_ptr() const + 0xa60 (0x7f32bbb33480 in /home/cy/anaconda3/envs/NHR/lib/python3.6/ site-packages/pointnet2-0.0.0-py3.6-linux-x86_64.egg/pointnet2_cuda.cpython-36m-x86_64-linux-gnu.so)
frame #2: group_points_wrapper_fast(int, int, int, int, int, at::Tensor, at::Tensor, at::Tensor) + 0x27 (0x7f32bbb34427 in /home/cy/anaconda3/envs/NHR/lib/python3.6/site-packages/pointnet2-0.0.0-py3.6-linux-x86_64.egg/pointnet2_cuda.cpython-36m -x86_64-linux-gnu.so)
frame #3: + 0x14947 (0x7f32bbb2c947 in /home/cy/anaconda3/envs/NHR/lib/python3.6/site-packages/pointnet 2-0.0.0-py3.6-linux-x86_64.egg/pointnet2_cuda.cpython-36m-x86_64-linux-gnu.so)
frame #4: + 0x11a06 (0x7f32bbb29a06 in /home/cy/anaconda3/envs/NHR/lib/python3.6/site-packages/pointnet 2-0.0.0-py3.6-linux-x86_64.egg/pointnet2_cuda.cpython-36m-x86_64-linux-gnu.so)

frame #11: THPFunction_apply(_object*, _object*) + 0xa1f (0x7f330e1f6e3f in /home/cy/anaconda3/envs/NHR/lib/python3.6/site -packages/torch/lib/libtorch_python.so)

then I found that the error occurred on the line 40 of pointnet2_modules.py, which is
new_features = self.mlps[i](new_features).
The type of ‘new_features’ as input variable is 'torch.float32', but the type of output of 'self.mlps' is 'torch.float16'.

@wuminye
Copy link
Owner

wuminye commented Mar 15, 2021

This error is usually seen when latest apex module is used. In our implementation, we use an older version (https://github.com/NVIDIA/apex/tree/088985936518be7e25795a30d8ab33affa9db6ed). I suggest downloading and recompiling the old one.

An alternative is to turn off the apex. In such a way, you should remove apex stuffs in train_net.py and engine/trainer.py.

@ghost
Copy link
Author

ghost commented Mar 16, 2021

This error is usually seen when latest apex module is used. In our implementation, we use an older version (https://github.com/NVIDIA/apex/tree/088985936518be7e25795a30d8ab33affa9db6ed). I suggest downloading and recompiling the old one.

An alternative is to turn off the apex. In such a way, you should remove apex stuffs in train_net.py and engine/trainer.py.

我修改了pointnet2_modules.py的第154行new_features = self.mlp(new_features).type(torch.float32)和第40行new_features = self.mlps[i](new_features).type(torch.float32),修改之后可以正常运行,请问这样解决是否合理呢?

@wuminye
Copy link
Owner

wuminye commented Mar 16, 2021

This error is usually seen when latest apex module is used. In our implementation, we use an older version (https://github.com/NVIDIA/apex/tree/088985936518be7e25795a30d8ab33affa9db6ed). I suggest downloading and recompiling the old one.
An alternative is to turn off the apex. In such a way, you should remove apex stuffs in train_net.py and engine/trainer.py.

我修改了pointnet2_modules.py的第154行new_features = self.mlp(new_features).type(torch.float32)和第40行new_features = self.mlps[i](new_features).type(torch.float32),修改之后可以正常运行,请问这样解决是否合理呢?

Nice try 👍
I don't think it's an efficient way, but it may work.

@ghost ghost closed this as completed Mar 18, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant