Comments (31)
@szagoruyko Could you please try opening torch in any directory other than repo's root? It's trying to load the torch
dir instead of the python package and gives you this error.
from pytorch.
could you tell me whats the meaning of ' opening torch in any directory other than repo's root '
from pytorch.
hahaha
from pytorch.
made the same mistake 😄
from pytorch.
@apaszke can you add 16.04 to the build matrix
from pytorch.
16.04 is not supported looks like it. i'll try to setup an ec2 based contbuild tomorrow
from pytorch.
@soumith the error on 14.04 is the same
from pytorch.
@apaszke works :P so lame
from pytorch.
Hi, I met the same problem when installing PyTorch with Python 2.7.13, centos 7 and Anaconda 4.3.0 (64-bit). I also use '/root/anaconda2/bin/python' to launch python as soumith taught me in #574. Finally, it met the same problem. In addition, I installed torch 7 in another package before installing pytorch. torch can be launched standalone with 'th' in the pytorch package. Would you mind give me a hint?
The installing way is written as follows:
git clone https://github.com/pytorch/pytorch
pip install -r requirements.txt
python setup.py install
After that, the system told me that PyTorch is installed. Then I wrote down 'python' in the prompt command line. At last, 'import torch' was entered in the python command line. Unfortunately , I got the following information:
Traceback (most recent call last):
File "", line 1, in
File "torch/init.py", line 45, in
from torch._C import *
ImportError: No module named _C
The package /usr/lib/python2.7/site-packages has no torch package. The pytorch has a package torch, and has the following files:
[root@AliHPC-M40-434 torch]# ls -ll
total 236
drwxr-xr-x 3 root root 150 Feb 10 11:54 autograd
drwxr-xr-x 3 root root 48 Feb 10 11:54 backends
drwxr-xr-x 9 root root 4096 Feb 10 11:54 csrc
drwxr-xr-x 2 root root 109 Feb 10 11:54 cuda
drwxr-xr-x 2 root root 83 Feb 10 11:54 distributed
-rw-r--r-- 1 root root 2218 Feb 10 11:54 functional.py
-rw-r--r-- 1 root root 7768 Feb 10 11:54 init.py
-rw-r--r-- 1 root root 8762 Feb 10 13:49 init.pyc
drwxr-xr-x 4 root root 61 Feb 10 11:54 legacy
drwxr-xr-x 15 root root 4096 Feb 10 12:00 lib
drwxr-xr-x 2 root root 93 Feb 10 11:54 multiprocessing
drwxr-xr-x 6 root root 4096 Feb 10 11:54 nn
drwxr-xr-x 2 root root 4096 Feb 10 11:54 optim
-rw-r--r-- 1 root root 12581 Feb 10 11:54 serialization.py
drwxr-xr-x 2 root root 32 Feb 10 11:54 sparse
-rw-r--r-- 1 root root 3354 Feb 10 11:54 storage.py
-rw-r--r-- 1 root root 33716 Feb 10 11:54 _tensor_docs.py
-rw-r--r-- 1 root root 17009 Feb 10 11:54 tensor.py
-rw-r--r-- 1 root root 10346 Feb 10 11:54 _tensor_str.py
drwxr-xr-x 2 root root 71 Feb 10 11:55 _thnn
-rw-r--r-- 1 root root 99370 Feb 10 11:54 _torch_docs.py
drwxr-xr-x 6 root root 145 Feb 10 11:54 utils
-rw-r--r-- 1 root root 2532 Feb 10 11:54 _utils.py
-rw-r--r-- 1 root root 2895 Feb 10 13:49 _utils.pyc
from pytorch.
you dont have to report it twice, i will reply on the other thread
from pytorch.
Thank you very much @soumith . I will not repeat it next time.
from pytorch.
@LinMaris, If your repo's root (for example) is in /home/dongki/library/pytorch
, then please move to a different directory other than the repo's root (e.g., cd /home/dongki/
) and open the torch. :-)
from pytorch.
i use import torch and appear torch/_C.cpython-35m-x86_64-linux-gnu.so: undefined symbol: THManageeSharedAllocator thankyou
from pytorch.
@apaszke I just trying to build the documentation in pytorch/docs and I get this message
cd ~/pytorch/docs
make html
Traceback (most recent call last):
File "source/scripts/build_activation_images.py", line 8, in <module>
import torch.nn.modules.activation
File "/home/ubuntu/pytorch/torch/__init__.py", line 84, in <module>
from torch._C import *
ImportError: No module named _C
Makefile:17: recipe for target 'figures' failed
make: *** [figures] Error 1
from pytorch.
Could be related to this #5490 ?
I am building in a container
from pytorch.
Sorry for the inconvenience, I solved overriding the Makefile PYCMD variable
:D
from pytorch.
@szagoruyko Could you please try opening torch in any directory other than repo's root? It's trying to load the
torch
dir instead of the python package and gives you this error.
I'm having this issue, can you explain what it means and how to ''solve'' it ?
from pytorch.
@CedricBeaulac what is the script you using to build it that gives you that error ?
from pytorch.
The script ? A simple
import torch
produces the following error
ModuleNotFoundError: No module named 'torch._C'
I've had extensive issues distinguishing bettwen the path, the interpreter path and how pip installs and conda installs interact with all of these things.
from pytorch.
Hi again @CedricBeaulac ,
I meant the script are you using to build pytorch from the source. Because this kind of problem is not a concern if you are just installing it from pip or conda. the problem lies on how are you building and installing your package.
from pytorch.
I'm really running a big file but sadly problem"no module named torch._c"showed up.I just copied "pytorch " from a friend's laptop,but still comes the problem.Hope someone to give me the solution!!
from pytorch.
Hi @reRaymond ,
Did your friend build pytorch on his laptop ?
If so you will need to have the same structure and packages installed.
from pytorch.
i aslo met the same problem: from torch._C import * ModuleNotFoundError: No module named 'torch._C'
i install anconda3 and i built a virtual environment named tensorflow. Then i installed torch,but it seems to install on the D:\Anconda3_4.4.0\Lib\site-packages,not in my Virtual environment tensorflow.So i install again in the D:\Anconda3_4.4.0\envs\tensorflow\Lib\site-packages.But when i import torch In this directory it met the problem.However,i import torch in other directory then it success! Please help me how to solve this. i want use import torch in my Virtual environment.
from pytorch.
Hi @reRaymond ,
Did your friend build pytorch on his laptop ?
If so you will need to have the same structure and packages installed.
Thank you sooooo much ,i've got my problem solved,using a right version.thank you again!!
from pytorch.
i aslo met the same problem: from torch._C import * ModuleNotFoundError: No module named 'torch._C'
i install anconda3 and i built a virtual environment named tensorflow. Then i installed torch,but it seems to install on the D:\Anconda3_4.4.0\Lib\site-packages,not in my Virtual environment tensorflow.So i install again in the D:\Anconda3_4.4.0\envs\tensorflow\Lib\site-packages.But when i import torch In this directory it met the problem.However,i import torch in other directory then it success! Please help me how to solve this. i want use import torch in my Virtual environment.
well,i've got my problem solved by now.but i'm not using a virtual environment.here's my advice for you.First thing to know is that torch version has to be suitable,which means,you'll need to visit https://pytorch.org.and download your one,attention to those choices while download.hope you get it through,because it's such a torment
from pytorch.
@reRaymond ,i use the correct version.It may not related to the problem. But,thank you very much!
from pytorch.
i aslo met the same problem: from torch._C import * ModuleNotFoundError: No module named 'torch._C'
i install anconda3 and i built a virtual environment named tensorflow. Then i installed torch,but it seems to install on the D:\Anconda3_4.4.0\Lib\site-packages,not in my Virtual environment tensorflow.So i install again in the D:\Anconda3_4.4.0\envs\tensorflow\Lib\site-packages.But when i import torch In this directory it met the problem.However,i import torch in other directory then it success! Please help me how to solve this. i want use import torch in my Virtual environment.
Hi
sorry but, are you sure the environment was enable before installing or using torch package ?
Your description is very confuse and lacking so many details.
from pytorch.
@apaszke works :P so lame
what was the exact thing that you did to resolve this issue>??
from pytorch.
I am getting the same error:
from torch._C import *
ModuleNotFoundError: No module named 'torch._C'
I am on a windows system.
My torch packages are in "D:\Anaconda3_32\Lib\torch"
what should i do??
from pytorch.
I am getting the same error:
from torch._C import *
ModuleNotFoundError: No module named 'torch._C'I am on a windows system.
My torch packages are in "D:\Anaconda3_32\Lib\torch"what should i do??
I meet the same error and I use windows too. Have you figure it out? If you find the solution, can you send a email to [email protected]? Thank you very much. Maybe we will meet the same problems in the future.
from pytorch.
import torch
NameError Traceback (most recent call last)
in
----> 1 import torch
C:\ProgramData\Anaconda3\lib\site-packages\torch_init_.py in
227
228
--> 229 all += [name for name in dir(C)
230 if name[0] != '' and
231 not name.endswith('Base')]
NameError: name '_C' is not defined
I am having this error during importing the torch package. Even I search a couple of solutions from the internet. Mostly all said the same "the problem is that you have a folder called torch in the same directory which is being picked up. Do this: cd .. (to change directory), and then start python and import torch, it should work."
But I not getting which directory to.. also I change a couple of paths but it not working. Any idea??????
@soumith
from pytorch.
Related Issues (20)
- compiling profiler with ExecutionTraceObserver breaks HOT 1
- [export] Llama3 export with dynamic shapes fails with constraint violations HOT 5
- [feature request] allow torch.compile calls with compiler options, but without modifying global dynamo options
- Option to hard fail for cudagraphs and/or more cudagraph logging HOT 1
- torch.export of ResNet with dynamic height fails due to constraint violation HOT 2
- DISABLED test_no_requires_grad_inplace (__main__.TestAutogradWithCompiledAutograd) HOT 2
- DISABLED test_aot_module_simplified_dynamic (__main__.TestAOTModuleSimplified) HOT 5
- `torch.histc` does not work with `torch.compile(dynamic=True)` HOT 2
- Request for Implementation of 'aten::isin.Tensor_Tensor_out' Operation on MPS Device HOT 4
- optim.apply_optimizer_in_backward does not account for gradient accumulation HOT 2
- decide how dynamo/export should handle parametrizations HOT 1
- `aot_module` + `torch.onnx.export` bug or user error?
- DISABLED test_alibi_bias_float32 (__main__.TestTemplatedSDPA) HOT 2
- DISABLED test_no_unnecessary_save (__main__.TestAutogradWithCompiledAutograd) HOT 1
- Add option to `torch.load(mmap=True)` to do `MAP_SHARED` rather than `MAP_PRIVATE` HOT 1
- DISABLED test_binary_op_list_error_cases__foreach_add_cuda_complex64 (__main__.TestForeachCUDA) HOT 1
- `torch.func.jvp` yields different output compared to original function with `torch.nn.functional.layer_norm`
- Not loading optimizer state separately from checkpoint causes errors with FQNs HOT 2
- Profiler does not record CUDA times
- `torch.func.linearize` fails when linearizing functions of gradients
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pytorch.