Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 736643 - sci-libs/pytorch-1.6.0::science: error when importing torch in python at runtime
Summary: sci-libs/pytorch-1.6.0::science: error when importing torch in python at runtime
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Overlays (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Alexey Chernov
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-08-10 15:35 UTC by Hendrik Klug
Modified: 2020-08-19 11:56 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
build.log of emerge pytorch (build.log,5.64 KB, text/plain)
2020-08-19 11:56 UTC, Hendrik Klug
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hendrik Klug 2020-08-10 15:35:44 UTC
I have emerged sci-libs/pytorch-1.6.0 however I get following error when I try to import it in python:

'''
python -c "import torch"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib64/python3.6/site-packages/torch/__init__.py", line 188, in <module>
    _load_global_deps()
  File "/usr/lib64/python3.6/site-packages/torch/__init__.py", line 141, in _load_global_deps
    ctypes.CDLL(lib_path, mode=ctypes.RTLD_GLOBAL)
  File "/usr/lib64/python3.6/ctypes/__init__.py", line 348, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: /usr/lib64/python3.6/site-packages/torch/lib/libtorch_global_deps.so: cannot open shared object file: No such file or directory
'''

Is there any way I can solve this?
Comment 1 Hendrik Klug 2020-08-10 15:38:06 UTC
eix -v pytorch
* sci-libs/pytorch [1]
     Available versions:  (~)1.4.0_p0 (~)1.6.0
     IUSE (all versions): asan atlas cuda eigen +fbgemm ffmpeg gflags glog +gloo leveldb lmdb mkl mkldnn mpi namedtensor +nnpack numa +numpy +observers +openblas opencl opencv +openmp +python +qnnpack redis static tbb test tools zeromq
     Installed versions:  Version:   1.6.0
                          Date:      12:05:25 09/08/20
                          USE:       fbgemm gloo nnpack numpy observers openblas openmp python qnnpack -asan -atlas -cuda -eigen -ffmpeg -gflags -glog -leveldb -lmdb -mkl -mkldnn -mpi -namedtensor -numa -opencl -opencv -redis -static -test -tools -zeromq PYTHON_TARGETS="python3_6"
                          DEPEND:    dev-libs/protobuf dev-python/pyyaml[python_targets_python3_6(-),-python_single_target_python3_6(-)] dev-python/numpy[python_targets_python3_6(-),-python_single_target_python3_6(-)] sci-libs/openblas dev-lang/python:3.6 >=dev-lang/python-exec-2:2/2=[python_targets_python3_6(-),-python_single_target_python3_6(-)] dev-python/pybind11[python_targets_python3_6(-),-python_single_target_python3_6(-)] dev-libs/libuv dev-python/setuptools[python_targets_python3_6(-),-python_single_target_python3_6(-)] dev-cpp/tbb app-arch/zstd dev-python/protobuf-python[python_targets_python3_6(-),-python_single_target_python3_6(-)] dev-python/pybind11[python_targets_python3_6(-),-python_single_target_python3_6(-)] sys-fabric/libibverbs sys-process/numactl
                          RDEPEND:   dev-libs/protobuf dev-python/pyyaml[python_targets_python3_6(-),-python_single_target_python3_6(-)] dev-python/numpy[python_targets_python3_6(-),-python_single_target_python3_6(-)] sci-libs/openblas dev-lang/python:3.6 >=dev-lang/python-exec-2:2/2=[python_targets_python3_6(-),-python_single_target_python3_6(-)] dev-python/pybind11[python_targets_python3_6(-),-python_single_target_python3_6(-)] dev-libs/libuv dev-lang/python:3.6 >=dev-lang/python-exec-2:2/2=[python_targets_python3_6(-),-python_single_target_python3_6(-)]
                          BDEPEND:   dev-lang/python:3.6 >=dev-lang/python-exec-2:2/2=[python_targets_python3_6(-),-python_single_target_python3_6(-)] >=dev-python/setuptools-42.0.2[python_targets_python3_6(-),-python_single_target_python3_6(-)] dev-util/ninja >=dev-util/cmake-3.9.6
                          SRC_URI:   
                          EAPI:      7
     Best versions/slot:  (~)1.6.0
     Homepage:            https://pytorch.org/
     Description:         Tensors and Dynamic neural networks in Python with strong GPU acceleration
     License:             BSD

[1] "science" /var/lib/overlays/science
Comment 2 Sam James archtester Gentoo Infrastructure gentoo-dev Security 2020-08-11 01:51:09 UTC
Oh wait. This is from ::science.
Comment 3 Benda Xu gentoo-dev 2020-08-11 04:42:12 UTC
Thanks I can reproduce this error.
Comment 4 Larry the Git Cow gentoo-dev 2020-08-11 13:44:24 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/proj/sci.git/commit/?id=72df8ef8dc56f868d4feaf7b558e93562b7627f3

commit 72df8ef8dc56f868d4feaf7b558e93562b7627f3
Author:     Benda Xu <heroxbd@gentoo.org>
AuthorDate: 2020-08-11 13:41:24 +0000
Commit:     Benda Xu <heroxbd@gentoo.org>
CommitDate: 2020-08-11 13:44:16 +0000

    sci-libs/pytorch: donot hardcode the library path.
    
    Closes: https://bugs.gentoo.org/736643
    Package-Manager: Portage-2.3.88, Repoman-2.3.18
    Signed-off-by: Benda Xu <heroxbd@gentoo.org>

 sci-libs/pytorch/files/pytorch-1.6.0-global-dlopen.patch | 15 +++++++++++++++
 sci-libs/pytorch/pytorch-1.6.0.ebuild                    |  3 ++-
 2 files changed, 17 insertions(+), 1 deletion(-)
Comment 5 Hendrik Klug 2020-08-11 17:48:09 UTC
Thanks!
Comment 6 Benda Xu gentoo-dev 2020-08-12 00:15:08 UTC
Hendrik, thanks for reporting!
Comment 7 Hendrik Klug 2020-08-19 11:56:08 UTC
Created attachment 655478 [details]
build.log of emerge pytorch

Hello Benda,
I am trying to emerge pytorch with cuda enabled now, but I get an error with the global-dlopen.patch (see attachment for full log): 
```
 * ERROR: sci-libs/pytorch-1.6.0::science failed (prepare phase):                                                                      
 *   patch -p1  failed with /var/tmp/portage/sci-libs/pytorch-1.6.0/files/pytorch-pytorch-1.6.0-global-dlopen.patch  
```

Am I doing something wrong?
The patch was working fine without cuda enabled.