Skip to content

Instantly share code, notes, and snippets.

@loosechainsaw
Created October 28, 2019 07:18
Show Gist options
  • Save loosechainsaw/8614453d7aa864bbdce386d439144a2d to your computer and use it in GitHub Desktop.
Save loosechainsaw/8614453d7aa864bbdce386d439144a2d to your computer and use it in GitHub Desktop.
NVIDIA Cuda Dev Env
#!/bin/bash
docker build --no-cache=true --build-arg USER="$1" -t "cudadev:v1.0.0" .
FROM nvidia/cuda:10.1-devel-ubuntu18.04
RUN echo "Setting Environment..."
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES all
ARG USER
RUN echo "Updating Package Index and Upgrading..."
RUN apt update && \
apt-get --yes upgrade && \
apt-get --yes install build-essential software-properties-common && \
add-apt-repository universe && \
add-apt-repository multiverse && \
apt update && \
apt-get --yes upgrade
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata
RUN echo "Installing build tools..." && \
apt-get install --no-install-recommends -y libjemalloc-dev liborc-dev autopoint g++-6 \
build-essential gcc-6 gcc-7 gcc-8 autoconf automake texinfo wget unzip sudo g++-8 \
libtool pkg-config make ninja-build valgrind ccache libglew-dev freeglut3-dev g++-7 \
locales iproute2 wget git git-core doxygen file cmake gettext ssh linux-tools-common \
sudo gcovr gperf lcov vim xvfb xz-utils socat openjdk-11-jre openjdk-11-jdk libxrender1 \
python3-pip libgtk-3-common libxtst6 libfreetype6-dev libxi6 net-tools yasm gdb htop
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave /usr/bin/g++ g++ /usr/bin/g++-6 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 70 --slave /usr/bin/g++ g++ /usr/bin/g++-7 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8
RUN locale-gen en_US.UTF-8
ENV LANG en_US.UTF-8
ENV LANGUAGE en_US:en
ENV LC_ALL en_US.UTF-8
WORKDIR /opt
RUN echo "Retreiving CLion and installing..." && \
wget "https://download-cf.jetbrains.com/cpp/CLion-2019.2.4.tar.gz" && \
tar -xvzf CLion-2019.2.4.tar.gz && \
mv clion-2019.2.4 clion
RUN echo "Adding and configuring user account ${USER}" && \
useradd -m -G plugdev ${USER} && \
usermod -aG sudo ${USER} && \
echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers && \
chown -R ${USER}:${USER} /home/${USER} && \
chown -R ${USER}:${USER} /opt/clion && \
sudo sh -c 'echo kernel.perf_event_paranoid=1 >> /etc/sysctl.d/99-perf.conf' && \
sudo sh -c 'echo kernel.kptr_restrict=0 >> /etc/sysctl.d/99-perf.conf' && \
sudo sh -c 'sysctl --system'
WORKDIR /
USER ${USER}
WORKDIR /opt/clion/bin
CMD ./clion.sh
#!/bin/bash
docker run --network host --cap-add=SYS_PTRACE --security-opt seccomp=unconfined --runtime=nvidia --env="DISPLAY" --env="QT_X11_NO_MITSHM=1" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" --name cudadev cudadev:v1.0.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment