torch-js icon indicating copy to clipboard operation
torch-js copied to clipboard

Missing some binary in distributed prebuilt

Open lamhoangtung opened this issue 4 years ago • 5 comments

Error message indicate this bug:

Error: libgomp-7c85b1e2.so.1: cannot open shared object file: No such file or directory

libgomp-7c85b1e2.so.1 was available in /torch-js/build/libtorch/lib/libgomp-a34b3233.so.1 when build from source and when unzip libtorch downloaded from pytorch.org. But some how cmake-js and prebuilt does not include any .so.1 file with the distributed prebuilt

A temporary workarround on Linux is to create some symlink:

/usr/lib/x86_64-linux-gnu/libgomp-7c85b1e2.so.1 -> /usr/lib/x86_64-linux-gnu/libgomp.so.1
/usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudart-6d56b25a.so.11.0 -> /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudart.so.11.0
/usr/local/cuda-11.1/targets/x86_64-linux/lib/libnvToolsExt-24de1d56.so.1 -> /usr/local/cuda-11.1/targets/x86_64-linux/lib/libnvToolsExt.so.1

Also 1080Ti also having this issue:

libcudart.so.10.2: cannot open shared object file: No such file or directory

Will investigate later cc @b21quocbao

lamhoangtung avatar Apr 16 '21 10:04 lamhoangtung

I've needed this project. I found that for docker container created using the following works (solves both Linux and 1080Ti issues)

Dockerfile

FROM nvidia/cuda:11.1.1-devel-ubuntu18.04

RUN apt-get update

# Install python et al.
RUN apt-get install python3.8 python3-pip wget curl gcc-8 unzip libssl1.0.0 software-properties-common -y
RUN add-apt-repository ppa:ubuntu-toolchain-r/test
RUN apt-get update
# https://stackoverflow.com/questions/63190229/glibcxx-3-4-26-not-found-running-cross-complied-program-on-beaglebone
RUN apt-get install --only-upgrade libstdc++6 -y

# Link extra packages
RUN ln -sf /usr/lib/x86_64-linux-gnu/libgomp.so.1 /usr/lib/x86_64-linux-gnu/libgomp-7c85b1e2.so.1
RUN ln -sf /app/node_modules/@techainer1t/torch-js/build/Release/libc10_cuda.so /usr/lib/x86_64-linux-gnu/libc10_cuda.so
RUN ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libcudart.so.11.0 /usr/lib/x86_64-linux-gnu/libcudart-6d56b25a.so.11.0
RUN ln -sf /usr/local/cuda-11.1/targets/x86_64-linux/lib/libnvToolsExt.so.1 /usr/lib/x86_64-linux-gnu/libnvToolsExt-24de1d56.so.1

# Installing node
RUN curl -sL https://deb.nodesource.com/setup_14.x | bash -
RUN apt-get install nodejs -y

RUN npm i -g @types/node typescript ts-node

WORKDIR /app

COPY requirements.txt /app/requirements.txt
RUN pip3 install -r requirements.txt
RUN rm requirements.txt

COPY package.json /app/package.json
COPY package-lock.json /app/package-lock.json

RUN npm install

COPY ./index.js /app/index.js
RUN ts-node index.js

# CMD ["node", "./index.js"]

requirements.txt

torch==1.8.1

package.json

{
  "name": "",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@techainer1t/torch-js": "^0.13.0"
  }
}

index.js

const torch = require("@techainer1t/torch-js");
const modelPath = `/app/model.pt`;

(async () => {
  console.log(torch)
  const model = new torch.ScriptModule(modelPath);
  const inputA = torch.rand([1, 5]);
  const inputB = torch.rand([1, 5]);
  const res = await model.forward(inputA, inputB);
  console.log(res)
})();

jeswr avatar Jul 13 '21 00:07 jeswr

Thanks for the dockerfile @jeswr. We will fix this completely on the next release

lamhoangtung avatar Jul 13 '21 01:07 lamhoangtung

Thanks for the dockerfile @jeswr. We will fix this completely on the next release

Thanks a lot! Thanks for your work on this package.

I was wondering if you have (or anyone else has) a quick workaround for the libcudart.so.10.2: cannot open shared object file: No such file or directory issue?

credwood avatar Sep 30 '21 22:09 credwood

How did you install CUDA on your os @credwood ?

lamhoangtung avatar Oct 01 '21 07:10 lamhoangtung

How did you install CUDA on your os @credwood ?

I am using the relevant parts of the Dockerfile above with the same base image nvidia/cuda:11.1.1-devel-ubuntu18.04. Thanks again @lamhoangtung

credwood avatar Oct 01 '21 15:10 credwood