Last active
August 18, 2024 13:24
-
-
Save sgqy/b5ef38fb83825a8494f66260a5598a5c to your computer and use it in GitHub Desktop.
code-server with golang and cuda
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
services: | |
vscode: | |
build: | |
context: . | |
image: code-server:custom | |
restart: always | |
shm_size: "32gb" | |
volumes: | |
- ./local:/home/coder/.local | |
- ./config:/home/coder/.config | |
- ./data:/home/coder/project | |
ports: | |
- 6100:8080 | |
deploy: | |
resources: | |
reservations: | |
devices: | |
- driver: nvidia | |
capabilities: ["gpu"] | |
count: all |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM codercom/code-server:bookworm | |
# Use root to install tools | |
USER 0 | |
# Install C++ | |
RUN --mount=type=tmpfs,target=/dev/shm bash <<EOF | |
set -euxo pipefail | |
cd /dev/shm | |
apt update | |
apt dist-upgrade -y | |
apt install -y curl vim jq | |
apt install -y build-essential autoconf automake libtool pkg-config | |
rm -rf /var/lib/apt/lists/* | |
rm -rf /dev/shm/* | |
EOF | |
# # Install CUDA | |
# RUN --mount=type=tmpfs,target=/dev/shm bash <<EOF | |
# set -euxo pipefail | |
# cd /dev/shm | |
# curl -fSLs -o cuda-key.deb 'https://developer.download.nvidia.com/compute/cuda/repos/debian12/x86_64/cuda-keyring_1.1-1_all.deb' | |
# dpkg -i cuda-key.deb | |
# apt update | |
# apt install -y cuda-toolkit cudnn | |
# >> /etc/profile.d/cuda.sh echo 'export PATH="\$PATH:/usr/local/cuda/bin"' | |
# rm -rf /var/lib/apt/lists/* | |
# rm -rf /dev/shm/* | |
# EOF | |
# Install Go | |
RUN --mount=type=tmpfs,target=/dev/shm bash <<EOF | |
set -euxo pipefail | |
cd /dev/shm | |
curl -fSLs -o go.json "https://go.dev/dl/?mode=json" | |
GO_VERSION=\$(jq -r '.[0].version' go.json) | |
GO_FILE=\$(jq -r '.[0].files[] | select(.arch == "amd64" and .os == "linux") | .filename' go.json) | |
GO_URL="https://go.dev/dl/\$GO_FILE" | |
curl -fSLs -o go.tar.gz "\$GO_URL" | |
tar -C /usr/local -xf go.tar.gz | |
>> /etc/profile.d/go.sh echo 'export GOPATH=/go' | |
>> /etc/profile.d/go.sh echo 'export PATH="\$PATH:/usr/local/go/bin:\$GOPATH/bin"' | |
mkdir /go | |
chown -R 1000:1000 /go | |
rm -rf /var/lib/apt/lists/* | |
rm -rf /dev/shm/* | |
EOF | |
# Install Python | |
RUN --mount=type=tmpfs,target=/dev/shm bash <<EOF | |
set -euxo pipefail | |
cd /dev/shm | |
apt update | |
apt install -y build-essential gdb lcov pkg-config libbz2-dev libffi-dev \ | |
libgdbm-dev libgdbm-compat-dev liblzma-dev libncurses5-dev \ | |
libreadline-dev libsqlite3-dev libssl-dev lzma lzma-dev tk-dev \ | |
uuid-dev zlib1g-dev | |
git clone --depth 1 --branch 3.12 'https://github.com/python/cpython' cpython | |
cd cpython | |
./configure --enable-optimizations | |
make -j | |
>> /etc/pip.conf echo '[global]' | |
>> /etc/pip.conf echo 'no-cache-dir = false' | |
env PIP_ROOT_USER_ACTION=ignore make install | |
rm -rf /var/lib/apt/lists/* | |
rm -rf /dev/shm/* | |
EOF | |
# Switch back to prepare apps | |
USER 1000 | |
# Install Python venv | |
RUN bash <<EOF | |
set -euxo pipefail | |
cd "\$HOME" | |
python3 -m venv .venv | |
source "\$HOME/.venv/bin/activate" | |
pip install -U ipykernel | |
deactivate | |
EOF | |
# Python libs | |
RUN bash <<EOF | |
set -euxo pipefail | |
source "\$HOME/.venv/bin/activate" | |
pip install -U numpy scipy matplotlib pandas scikit-learn | |
deactivate | |
EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment