Skip to content
New issue

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

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

Already on GitHub? # to your account

No module named 'torch._c' #4

Open
marcusvlc opened this issue Aug 22, 2019 · 22 comments
Open

No module named 'torch._c' #4

marcusvlc opened this issue Aug 22, 2019 · 22 comments

Comments

@marcusvlc
Copy link
Contributor

marcusvlc commented Aug 22, 2019

Im trying to install torch on raspberry pi 3 B+ with your .whl files, but im gotting the following error:

No module named 'torch._c'

pytorch installs normally, the error comes up when I try to import

I searched on the internet but found nothing. Can you help me?

Im using raspibian lite, python3.7 and i alredy installed all libraries.

I tried to install the torch-1.1.0 cp37 armv7l

@nmilosev
Copy link
Owner

Raspberry Pi 3 should be ARM64, so you should use aarch64 build?

@marcusvlc
Copy link
Contributor Author

marcusvlc commented Aug 23, 2019

I was unable to install the armv6l and aarch64 files because it says they are not compatible with this platform. The only one I could install was armv7l but I got the error I described above.

Obs -- Raspbiain lite (my current system) is armv7l

@nmilosev
Copy link
Owner

Could you please provide the output of uname -a? Thanks!

@marcusvlc
Copy link
Contributor Author

uname -a on raspibian lite returns armv7l.

@nmilosev
Copy link
Owner

Please see the discussion in #3 about this issue. I think you need an actual 64-bit OS to run pytorch for 64 bits.

@marcusvlc
Copy link
Contributor Author

I also tried to install the aarch version on aarch64 ubuntu mate 64 bits for raspberry pi. Im getting error with a version of a library, when i try to import the torch

ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found

@radiodee1
Copy link

ImportError: /usr/lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.26' not found

I get this error too. I'm using raspberrypi Buster. It seems libstdc++.so.6 in FC30 might be ahead of Buster on the raspberry pi. What could I do about this??

@nmilosev
Copy link
Owner

nmilosev commented Sep 2, 2019

Okay, thank you for the info. Really means a lot.

I checked my glibc version and indeed it is newer:

Name         : glibc
Version      : 2.29
Release      : 15.fc30
Architecture : x86_64
Size         : 25 M
Source       : glibc-2.29-15.fc30.src.rpm
Repository   : @System
From repo    : updates

What could I do about this??

Sadly not much. I don't think updating glibc is easy, as it would break the rest of your system.

I just had a thought, what about running a chroot? I have a tool made for that called anyfed (https://github.com/nmilosev/anyfed) or you could use Docker? That could work but I can't guarantee. Anyfed hasn't been updated in a while so I will update it today if you want to try it.

Of course it would be best to get Fedora on your device and use the builds that way. :)

https://wiki.debian.org/Debootstrap has an option for different architecture, which means that in theory you could make a chroot with Debian in it and compile Pytorch there, similar to how I am doing it with Fedora.

@radiodee1
Copy link

radiodee1 commented Sep 2, 2019 via email

@nmilosev
Copy link
Owner

nmilosev commented Sep 2, 2019

Okay, great! :)

Anyfed just updated to Fedora 30.

Cheers

@marcusvlc
Copy link
Contributor Author

@radiodee1 If all goes well, could you share the compiled pytorch and torchvision files? And also tell which system managed to install them.

@radiodee1
Copy link

I am interested in running a torch model on the raspberry pi 4. It has python 3.7

I got a virtualbox instance and I installed FC29 on it. I run ubuntu.

I followed the instructions for building the torch wheel, but I used FC29 everywhere that FC30 was specified. That's first. That means the one-liner in the instructions should read as follows:

sudo dnf install --releasever=29 --installroot=/tmp/F29ARM --forcearch=armv7hl --repo=fedora --repo=updates systemd passwd dnf fedora-release vim-minimal openblas-devel blas-devel m4 cmake python3-Cython python3-devel python3-yaml python3-setuptools python3-numpy python3-cffi python3-wheel gcc-c++ tar gcc git make tmux -y

After that I just followed the instructions. This took about 10 hours. Then I move the torch wheel to the pi and install with pip3.

Then, you need to follow the instructions here: pytorch/pytorch#574 . Basically you need to change the names of _C and _dl after you install the library with pip3.

After that it seems to work. I never tried torchvision.

I hesitate to share my wheel because technically it didn't work. You still have to modify the _C and _dl files after you install.

@nmilosev
Copy link
Owner

nmilosev commented Sep 3, 2019

This is great! So this is the possible solution to this problem, albeit manual. Still, better than building from source.

Thanks for your report. @marcusvlc Could you follow the instructions in the linked issue and try again?

@nmilosev
Copy link
Owner

nmilosev commented Sep 3, 2019

@radiodee1 Please share your whl so we can try it out.

@radiodee1
Copy link

how do i share my wheel?

@marcusvlc
Copy link
Contributor Author

@radiodee1 Thanks for you aswner, i will try it. Can you put you wheel file on a git repository (or google drive) and share with us?

@nmilosev
Copy link
Owner

nmilosev commented Sep 3, 2019

how do i share my wheel?

It would be best to attach it here in the issues?

@nmilosev
Copy link
Owner

nmilosev commented Sep 3, 2019

@radiodee1 Thanks for you aswner, i will try it. Can you put you wheel file on a git repository (or google drive) and share with us?

Please also try the original file for armv7?

@radiodee1
Copy link

I forked the repo and changed/added my whl file. See here: https://github.com/radiodee1/pytorch-arm-builds . Funny thing is, the author of the commit was recorded as someone else, not me.

@runninbear5
Copy link

runninbear5 commented Sep 8, 2019

@radiodee1

I have been trying to make my own .whl files similar to what you have done and I had a lot of trouble. I see here you said

I got a virtualbox instance and I installed FC29 on it. I run ubuntu.

I followed the instructions for building the torch wheel, but I used FC29 everywhere that FC30 was specified. That's first. That means the one-liner in the instructions should read as follows:

When you say you run ubuntu does that mean the machine you were running the vm on was an ubuntu machine? When I was struggling to get fedora running I was using a windows machine.

Could you document how you when about setting up the virtual machine to help in the future?

@nmilosev
Copy link
Owner

nmilosev commented Sep 8, 2019

Running Fedora in a VM for this purpose would not work. You need to virtuelize ARM with qemu and nested virtualization is tricky to say at least. You have to run on bare hardware.

@radiodee1
Copy link

Though I would agree that nested virtualization is not generally a good idea, I want to note that that is exactly what I did and I ended up with a wheel I could use. I don't recommend this for others but I wanted to note that that was my method. So I used ubuntu as my native operating system. I used virtualbox for my fist virtualization, and I used FC29 for the guest inside virtualbox. Then I used FC29 as the nested os for arm. I wanted to be really clear.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants