question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

import onnx fails due to version difference with caffe2 when installing using conda

See original GitHub issue

When I use Anaconda3 to install both Caffe2 and Onnx ‘import onnx’ fails. However, onnx by itself works fine, its only when paired with Caffe2 that there is a problem.

Below I have included steps to reproduce the error. The first test demonstrates that onnx alone is fine. The second test pairs it with caffe2 to cause the import error.

I would appreciate any insights or ideas to try to resolve the problem.

Thanks, Michael


System

Ubuntu 16.04LTS Anaconda3 version conda list anaconda # packages in environment at /home/mmajursk/anaconda3: # # Name Version Build Channel anaconda custom py36hbbc8b67_0
anaconda-client 1.6.9 py36_0
anaconda-navigator 1.7.0 py36_0
anaconda-project 0.8.2 py36h44fb852_0

Conda version conda --version conda 4.5.4


Sanity Test of just onnx

# Setup new virtual environment for testing
conda create --name test
conda activate test
# install onnx
conda install -c conda-forge onnx
# check install
conda list

# packages in environment at /home/mmajursk/anaconda3/envs/test:
# Name                    Version                   Build  Channel
ca-certificates           2018.4.16                     0    conda-forge
certifi                   2018.4.16                py35_0    conda-forge
libgcc-ng                 7.2.0                hdf63c60_3  
libgfortran-ng            7.2.0                hdf63c60_3  
libopenblas               0.2.20               h9ac9557_4  
libprotobuf               3.5.2                         0    conda-forge
libstdcxx-ng              7.2.0                hdf63c60_3  
ncurses                   5.9                          10    conda-forge
numpy                     1.14.3           py35h28100ab_1  
numpy-base                1.14.3           py35h0ea5e3f_1  
onnx                      1.1.2            py35h0c63530_0    conda-forge
openssl                   1.0.2o                        0    conda-forge
pip                       9.0.3                    py35_0    conda-forge
protobuf                  3.5.2                    py35_0    conda-forge
python                    3.5.5                         1    conda-forge
readline                  7.0                           0    conda-forge
setuptools                39.2.0                   py35_0    conda-forge
six                       1.11.0                   py35_1    conda-forge
sqlite                    3.20.1                        2    conda-forge
tk                        8.6.7                         0    conda-forge
wheel                     0.31.0                   py35_0    conda-forge
xz                        5.2.3                         0    conda-forge
zlib                      1.2.11                        0    conda-forge

Test onnx import

python -c 'import onnx'

Success 😃


Test with caffe2

conda create --name testcaffe2
conda activate testcaffe2

# install caffe2 with the correct version of cuda and cudnn
conda install -c caffe2 caffe2-cuda8.0-cudnn7
# check install
conda list caffe2
# Name                    Version                   Build  Channel
caffe2-cuda8.0-cudnn7     0.8.dev         py36_2018.05.14    caffe2

# install onnx via anaconda
conda install -c conda-forge onnx
# check install
conda list onnx
# Name                    Version                   Build  Channel
onnx                      1.0.1                    py36_1    conda-forge

Test onnx import

python -c 'import onnx'
# Results in
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/home/mmajursk/anaconda3/envs/testcaffe2/lib/python3.6/site-packages/onnx/__init__.py", line 10, in <module>
    import onnx.helper  # noqa
  File "/home/mmajursk/anaconda3/envs/testcaffe2/lib/python3.6/site-packages/onnx/helper.py", line 15, in <module>
    import onnx.defs as defs
  File "/home/mmajursk/anaconda3/envs/testcaffe2/lib/python3.6/site-packages/onnx/defs/__init__.py", line 6, in <module>
    import onnx.onnx_cpp2py_export.defs as C
ImportError: /home/mmajursk/anaconda3/envs/testcaffe2/lib/python3.6/site-packages/onnx/onnx_cpp2py_export.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZNK6google8protobuf7Message11GetTypeNameEv

Check complete conda package list

conda list
# packages in environment at /home/mmajursk/anaconda3/envs/testcaffe2:
#
# Name                    Version                   Build  Channel
blas                      1.0                         mkl  
bzip2                     1.0.6                h14c3975_5  
ca-certificates           2018.4.16                     0    conda-forge
caffe2-cuda8.0-cudnn7     0.8.dev         py36_2018.05.14    caffe2
cairo                     1.14.12              h7636065_2  
certifi                   2018.4.16                py36_0    conda-forge
ffmpeg                    3.4                  h7264315_0  
fontconfig                2.12.6               h49f89f6_0  
freeglut                  3.0.0                hf484d3e_5  
freetype                  2.8                  hab7d2ae_1  
future                    0.16.0                   py36_1  
gflags                    2.2.1                hf484d3e_0  
glib                      2.56.1               h000015b_0  
glog                      0.3.5                hf484d3e_1  
graphite2                 1.3.11               h16798f4_2  
harfbuzz                  1.7.6                h5f0a787_1  
hdf5                      1.10.1               h9caa474_1  
icu                       58.2                 h9c2bf20_1  
intel-openmp              2018.0.0                      8  
jasper                    2.0.14               h07fcdf6_1  
jpeg                      9b                   h024ee3a_2  
libedit                   3.1.20170329         h6b74fdf_2  
libffi                    3.2.1                hd88cf55_4  
libgcc-ng                 7.2.0                hdf63c60_3  
libgfortran-ng            7.2.0                hdf63c60_3  
libglu                    9.0.0                h0c0bdc1_1  
libopus                   1.2.1                hb9ed12e_0  
libpng                    1.6.34               hb9fc6fc_0  
libprotobuf               3.5.2                h6f1eeef_0  
libstdcxx-ng              7.2.0                hdf63c60_3  
libtiff                   4.0.9                he85c1e1_1  
libvpx                    1.6.1                h888fd40_0  
libxcb                    1.13                 h1bed415_1  
libxml2                   2.9.8                h26e45fe_1  
mkl                       2018.0.2                      1  
mkl_fft                   1.0.1            py36h3010b51_0  
mkl_random                1.0.1            py36h629b387_0  
ncurses                   6.1                  hf484d3e_0  
numpy                     1.14.3           py36hcd700cb_1  
numpy-base                1.14.3           py36h9be14a7_1  
onnx                      1.0.1                    py36_1    conda-forge
opencv                    3.3.1            py36h61133dd_2  
openssl                   1.0.2o                        0    conda-forge
pcre                      8.42                 h439df22_0  
pip                       10.0.1                   py36_0  
pixman                    0.34.0               hceecf20_3  
protobuf                  3.5.2            py36hf484d3e_0  
python                    3.6.5                hc3d631a_2  
readline                  7.0                  ha6073c6_4  
setuptools                39.1.0                   py36_0  
six                       1.11.0           py36h372c433_1  
sqlite                    3.23.1               he433501_0  
tk                        8.6.7                hc745277_3  
wheel                     0.31.1                   py36_0  
xz                        5.2.4                h14c3975_4  
zlib                      1.2.11               ha838bed_2  

onnx version differences between conda install results

Based on a diff on the two ‘conda list’ results there is a conflict with:

libprotobuf
    (test)libprotobuf               3.5.2                         0    conda-forge
    (testcaffe2)libprotobuf               3.5.2                h6f1eeef_0
protobuf
    (test)protobuf                  3.5.2                    py35_0    conda-forge
    (testcaffe2)protobuf                  3.5.2            py36hf484d3e_0
onnx 
    (test)onnx                      1.1.2            py35h0c63530_0    conda-forge
    (testcaffe2)onnx                      1.0.1                    py36_1    conda-forge

If I try to force conda to install onnx v1.1.2 within testcaffe2 environment conda tries to downgrade everything to python2.7

conda install -c conda-forge onnx=1.1.2
Solving environment: done

## Package Plan ##

  environment location: /home/mmajursk/anaconda3/envs/testcaffe2

  added / updated specs: 
    - onnx=1.1.2


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2018.4.16          |           py27_0         142 KB  conda-forge
    protobuf-3.5.2             |           py27_0         1.3 MB  conda-forge
    numpy-base-1.14.3          |   py27h9be14a7_1         4.1 MB
    six-1.11.0                 |           py27_1          20 KB  conda-forge
    wheel-0.31.0               |           py27_0          61 KB  conda-forge
    opencv-3.3.1               |   py27h61133dd_2        38.9 MB
    future-0.16.0              |           py27_0         665 KB  conda-forge
    mkl_random-1.0.1           |           py27_0         1.1 MB  conda-forge
    caffe2-cuda8.0-cudnn7-0.8.dev|  py27_2018.05.14        30.0 MB  caffe2
    numpy-1.14.3               |   py27hcd700cb_1          41 KB
    mkl_fft-1.0.2              |           py27_0         466 KB  conda-forge
    setuptools-39.2.0          |           py27_0         582 KB  conda-forge
    pip-9.0.3                  |           py27_0         1.8 MB  conda-forge
    python-2.7.15              |       h1571d57_0        12.1 MB
    onnx-1.1.2                 |   py27h0c63530_0         7.9 MB  conda-forge
    ------------------------------------------------------------
                                           Total:        99.2 MB

The following NEW packages will be INSTALLED:

    onnx:                  1.1.2-py27h0c63530_0    conda-forge

The following packages will be UPDATED:

    ca-certificates:       2018.03.07-0                        --> 2018.4.16-0             conda-forge
    caffe2-cuda8.0-cudnn7: 0.8.dev-py36_2018.05.14 caffe2      --> 0.8.dev-py27_2018.05.14 caffe2     
    certifi:               2018.4.16-py36_0                    --> 2018.4.16-py27_0        conda-forge
    mkl_fft:               1.0.1-py36h3010b51_0                --> 1.0.2-py27_0            conda-forge
    mkl_random:            1.0.1-py36h629b387_0                --> 1.0.1-py27_0            conda-forge
    numpy:                 1.14.3-py36hcd700cb_1               --> 1.14.3-py27hcd700cb_1              
    numpy-base:            1.14.3-py36h9be14a7_1               --> 1.14.3-py27h9be14a7_1              
    opencv:                3.3.1-py36h61133dd_2                --> 3.3.1-py27h61133dd_2               
    openssl:               1.0.2o-h20670df_0                   --> 1.0.2o-0                conda-forge
    protobuf:              3.5.2-py36hf484d3e_0                --> 3.5.2-py27_0            conda-forge
    setuptools:            39.1.0-py36_0                       --> 39.2.0-py27_0           conda-forge
    six:                   1.11.0-py36h372c433_1               --> 1.11.0-py27_1           conda-forge

The following packages will be DOWNGRADED:

    future:                0.16.0-py36_1                       --> 0.16.0-py27_0           conda-forge
    pip:                   10.0.1-py36_0                       --> 9.0.3-py27_0            conda-forge
    python:                3.6.5-hc3d631a_2                    --> 2.7.15-h1571d57_0                  
    wheel:                 0.31.1-py36_0                       --> 0.31.0-py27_0           conda-forge

Proceed ([y]/n)? 

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mmajurskicommented, Jun 27, 2018

I installed caffe2 using conda. See the top of my first post:

conda create --name testcaffe2 conda activate testcaffe2

install caffe2 with the correct version of cuda and cudnn

conda install -c caffe2 caffe2-cuda8.0-cudnn7

check install

conda list caffe2

Name Version Build Channel

caffe2-cuda8.0-cudnn7 0.8.dev py36_2018.05.14 caffe2

install onnx via anaconda

conda install -c conda-forge onnx

check install

conda list onnx

Name Version Build Channel

onnx 1.0.1 py36_1 conda-forge

0reactions
askhadecommented, Jun 25, 2021

Is this still relevant? Closing this now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Install | Caffe2
NOTE: This will install Caffe2 and all of its required dependencies into the current conda environment. We strongly suggest that you create a...
Read more >
libcaffeconverter import error for caffe to onnx - Stack Overflow
Workaround: Create a python 3.6 environment with your package manager of choice in the terminal: conda create -n <your env name here> python=3.6 ......
Read more >
Onnx Caffe2 - :: Anaconda.org
This library provides Caffe2 importer and exporter for the ONNX format.
Read more >
Comprehensive Guide: Installing Caffe2 with GPU Support by ...
If you have not installed CUDA toolkit, are unsure whether it is already installed, or want to install the newer version of CUDA...
Read more >
MMCV Installation — MMDetection 2.11.0 documentation
PyTorch/CUDA Environment¶ · Check you GCC version and use GCC 5.4. · Check whether PyTorch is correctly installed and could use CUDA op,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found