Skip to content

Instantly share code, notes, and snippets.

@rh314
Last active August 21, 2017 20:38
Show Gist options
  • Save rh314/bef5152b655286a8138edd7666789807 to your computer and use it in GitHub Desktop.
Save rh314/bef5152b655286a8138edd7666789807 to your computer and use it in GitHub Desktop.
Container setup to reproduce zmq + pytorch segfault
See Dockerfile and run-stuff.sh
# (Ubuntu 16.04, pytorch 0.2.0)
FROM ubuntu
COPY run-stuff.sh .
RUN chmod +x run-stuff.sh
RUN ./run-stuff.sh
# After image is created,
# 1) enter it interactively
# 2) Run python3
# 3) import zmq; import torch
# 4) Observe crash e.g.
# *** Error in `python3': free(): invalid pointer: 0x00007f98524c1b80 ***
# ======= Backtrace: =========
# /lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f986429c7e5]
# /lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f98642a537a]
# /lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f98642a953c]
# /usr/local/lib/python3.6/site-packages/torch/lib/libshm.so(_ZNSt6locale5_Impl16_M_install_facetEPKNS_2idEPKNS_5facetE+0x142)[0x7f985225b802]
# /usr/local/lib/python3.6/site-packages/torch/lib/libshm.so(_ZNSt6locale5_ImplC2Em+0x1e3)[0x7f985225d953]
# /usr/local/lib/python3.6/site-packages/torch/lib/libshm.so(_ZNSt6locale18_S_initialize_onceEv+0x15)[0x7f985225e8c5]
# /lib/x86_64-linux-gnu/libpthread.so.0(+0xea99)[0x7f98645fda99]
# /usr/local/lib/python3.6/site-packages/torch/lib/libshm.so(_ZNSt6locale13_S_initializeEv+0x21)[0x7f985225e911]
# /usr/local/lib/python3.6/site-packages/torch/lib/libshm.so(_ZNSt6localeC1Ev+0x13)[0x7f985225e953]
# /usr/local/lib/python3.6/site-packages/torch/lib/libshm.so(_ZNSt8ios_base4InitC1Ev+0xb4)[0x7f98522301b4]
# /usr/local/lib/python3.6/site-packages/torch/lib/libcusparse-652fe42d.so.7.5.18(+0x2a5a14)[0x7f982ee0ba14]
# /usr/local/lib/python3.6/site-packages/torch/lib/libcusparse-652fe42d.so.7.5.18(+0x2a6aa3)[0x7f982ee0caa3]
# /usr/local/lib/python3.6/site-packages/torch/lib/libcusparse-652fe42d.so.7.5.18(+0x335026)[0x7f982ee9b026]
#!/bin/bash
apt-get update
apt-get install -y ca-certificates ssl-cert sudo git build-essential \
zlib1g-dev wget libssl-dev nano libsqlite3-dev libncurses5-dev \
libreadline6-dev
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz
tar -xvf Python-3.6.2.tgz
cd Python-3.6.2
# Not needed now, but needed on "normal" ubuntu installs.
# echo sys.path.append\(\'/usr/lib/python3/dist-packages\'\) >> Lib/site.py
./configure --enable-shared LDFLAGS=-Wl,-rpath=/usr/local/lib
make
make install
pip3 install zmq
TORCH_WHL=torch-0.2.0.post1-cp36-cp36m-manylinux1_x86_64.whl
wget http://download.pytorch.org/whl/cu75/$TORCH_WHL
pip3 install $TORCH_WHL
pip3 install torchvision
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment