Skip to content

Commit ce66c03

Browse files
authored
fix error - context creation failed (#31)
1 parent 96c3afb commit ce66c03

File tree

2 files changed

+24
-15
lines changed

2 files changed

+24
-15
lines changed

Dockerfile

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM nvidia/cuda:11.4.2-cudnn8-devel-ubuntu18.04
1+
FROM nvidia/cuda:11.4.1-cudnn8-devel-ubuntu18.04
22

33
# Update default packages
44
RUN apt-get update
@@ -16,18 +16,22 @@ RUN curl https://sh.rustup.rs -sSf | bash -s -- -y
1616

1717

1818
# get prebuilt llvm
19-
# COPY clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-18.04.tar.xz .
2019
RUN curl -O https://releases.llvm.org/7.0.1/clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-18.04.tar.xz &&\
2120
xz -d /clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-18.04.tar.xz &&\
2221
tar xf /clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-18.04.tar &&\
2322
rm /clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-18.04.tar &&\
2423
mv /clang+llvm-7.0.1-x86_64-linux-gnu-ubuntu-18.04 /root/llvm
2524

2625
# set env
27-
ENV LLVM_CONFIG="/root/llvm/bin/llvm-config"
28-
ENV CUDA_ROOT="/usr/local/cuda"
26+
ENV LLVM_CONFIG=/root/llvm/bin/llvm-config
27+
ENV CUDA_ROOT=/usr/local/cuda
2928
ENV CUDA_PATH=$CUDA_ROOT
3029
ENV LLVM_LINK_STATIC=1
3130
ENV RUST_LOG=info
32-
ENV PATH="$CUDA_ROOT/nvvm/lib64:/root/.cargo/bin:$PATH"
33-
ENV LD_LIBRARY_PATH=$PATH
31+
ENV PATH=$CUDA_ROOT/nvvm/lib64:/root/.cargo/bin:$PATH
32+
33+
# make ld aware of necessary *.so libraries
34+
RUN echo $CUDA_ROOT/lib64 >> /etc/ld.so.conf &&\
35+
echo $CUDA_ROOT/compat >> /etc/ld.so.conf &&\
36+
echo $CUDA_ROOT/nvvm/lib64 >> /etc/ld.so.conf &&\
37+
ldconfig

guide/src/guide/getting_started.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This section covers how to get started writing GPU crates with `cuda_std` and `c
55
## Required Libraries
66

77
Before you can use the project to write GPU crates, you will need a couple of prerequisites:
8-
- [The CUDA SDK](https://developer.nvidia.com/cuda-downloads), version `11.2` or higher. This is only for building
8+
- [The CUDA SDK](https://developer.nvidia.com/cuda-downloads), version `11.2` or higher (and the appropriate driver - [see cuda release notes](https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html)) . This is only for building
99
GPU crates, to execute built PTX you only need CUDA 9+.
1010

1111
- LLVM 7.x (7.0 to 7.4), The codegen searches multiple places for LLVM:
@@ -18,6 +18,8 @@ GPU crates, to execute built PTX you only need CUDA 9+.
1818

1919
- You may also need to add `libnvvm` to PATH, the builder should do it for you but in case it does not work, add libnvvm to PATH, it should be somewhere like `CUDA_ROOT/nvvm/bin`,
2020

21+
- You may wish to use or consult the bundled [Dockerfile](#docker) to assist in your local config
22+
2123
## rust-toolchain
2224

2325
Currently, the Codegen only works on nightly (because it uses rustc internals), and it only works on a specific version of nightly.
@@ -194,12 +196,15 @@ Then execute it using cust.
194196
There is also a [Dockerfile](Dockerfile) prepared as a quickstart with all the necessary libraries for base cuda development.
195197

196198
You can use it as follows (assuming your clone of Rust-CUDA is at the absolute path `RUST_CUDA`):
197-
199+
- Ensure you have Docker setup to [use gpus](https://docs.docker.com/config/containers/resource_constraints/#gpu)
198200
- Build `docker build -t rust-cuda $RUST_CUDA`
199-
- Run `docker run -it -v $RUST_CUDA:/root/rust-cuda --entrypoint /bin/b
200-
ash rust-cuda`
201-
202-
Running will drop you into the container
203-
s shell and you will find the project at `~/rust-cuda`
204-
205-
Note: refer to [rust-toolchain][#rust-toolchain] to ensure you are using the correct toolchain in your project.
201+
- Run `docker run -it --gpus all -v $RUST_CUDA:/root/rust-cuda --entrypoint /bin/bash rust-cuda`
202+
* Running will drop you into the container's shell and you will find the project at `~/rust-cuda`
203+
- If all is well, you'll be able to `cargo run` in `~/rust-cuda/examples/cuda/cpu/add`
204+
205+
**Notes:**
206+
1. refer to [rust-toolchain](#rust-toolchain) to ensure you are using the correct toolchain in your project.
207+
2. despite using Docker, your machine will still need to be running a compatible driver, in this case for Cuda 11.4.1 it is >=470.57.02
208+
3. if you have issues within the container, it can help to start ensuring your gpu is recognized
209+
* ensure `nvidia-smi` provides meaningful output in the container
210+
* NVidia provides a number of samples https://github.com/NVIDIA/cuda-samples. In particular, you may want to try `make`ing and running the [`deviceQuery`](https://github.com/NVIDIA/cuda-samples/tree/ba04faaf7328dbcc87bfc9acaf17f951ee5ddcf3/Samples/deviceQuery) sample. If all is well you should see many details about your gpu

0 commit comments

Comments
 (0)