@@ -13,9 +13,9 @@ LABEL ubuntu.version="22.04"
1313#  Avoid interactive prompts during package installation
1414ARG  DEBIAN_FRONTEND=noninteractive
1515
16- #  Install essential development tools
16+ #  Install essential development tools for GPU programming 
1717RUN  apt-get update && apt-get install -y \
18-     #  Basic  development tools
18+     #  Core  development tools
1919    build-essential \
2020    cmake \
2121    git \
@@ -25,49 +25,33 @@ RUN apt-get update && apt-get install -y \
2525    nano \
2626    htop \
2727    tree \
28-     #  Python development 
28+     #  Minimal  Python for basic scripting (not data science) 
2929    python3 \
3030    python3-pip \
3131    python3-dev \
3232    #  Additional utilities
3333    pkg-config \
3434    software-properties-common \
35-     apt-transport-https \
36-     ca-certificates \
37-     gnupg \
38-     lsb-release \
39-     #  GPU monitoring tools
35+     #  GPU monitoring tools (installed but won't work during build)
4036    nvidia-utils-535 \
4137    #  Debugging and profiling tools
4238    gdb \
4339    valgrind \
4440    strace \
45-     #  Network tools for downloading samples 
41+     #  Network tools
4642    net-tools \
4743    iputils-ping \
4844    && rm -rf /var/lib/apt/lists/*
4945
50- #  Install NVIDIA profiling tools (Nsight Systems, Compute) - Latest 2025 versions
51- RUN  apt-get update && apt-get install -y \
52-     nsight-systems-2025.1.1 \
53-     nsight-compute-2025.1.1 \
54-     && rm -rf /var/lib/apt/lists/* || \
55-     #  Fallback to 2024 versions if 2025 not available yet
56-     (apt-get update && apt-get install -y \
57-     nsight-systems-2024.6.1 \
58-     nsight-compute-2024.3.1 \
59-     && rm -rf /var/lib/apt/lists/*)
60- 
61- #  Install Python packages for data analysis and visualization
46+ #  Install optional CUDA tools if available
47+ RUN  apt-get update && \
48+     (apt-get install -y cuda-tools-12-9 || apt-get install -y cuda-tools || true) && \
49+     rm -rf /var/lib/apt/lists/*
50+ 
51+ #  Install minimal Python packages for basic development (no heavy data science libs)
6252RUN  pip3 install --no-cache-dir \
6353    numpy \
64-     matplotlib \
65-     seaborn \
66-     pandas \
67-     jupyter \
68-     jupyterlab \
69-     plotly \
70-     scipy
54+     matplotlib
7155
7256#  Set up CUDA environment variables
7357ENV  PATH=/usr/local/cuda/bin:${PATH}
@@ -78,8 +62,8 @@ ENV CUDA_VERSION=12.9.1
7862ENV  NVIDIA_VISIBLE_DEVICES=all
7963ENV  NVIDIA_DRIVER_CAPABILITIES=compute,utility
8064
81- #  Verify CUDA installation
82- RUN  nvcc --version && nvidia-smi 
65+ #  Verify CUDA compiler  installation (skip nvidia-smi as no GPU during build) 
66+ RUN  nvcc --version
8367
8468#  Create development workspace
8569WORKDIR  /workspace
@@ -98,85 +82,85 @@ RUN echo 'alias ll="ls -alF"' >> /root/.bashrc && \
9882    echo 'export PS1="\[\e [1;32m\] [CUDA-DEV]\[\e [0m\]  \w  $ "'  >> /root/.bashrc
9983
10084#  Create a simple GPU test script
101- RUN  cat > /workspace/test-gpu.sh << 'EOF' 
102- # !/bin/bash
103- echo "=== GPU Programming 101 - CUDA Environment Test ===" 
104- echo "Date: $(date)" 
105- echo "" 
106- 
107- echo "=== CUDA Compiler ===" 
108- nvcc --version
109- echo "" 
110- 
111- echo "=== GPU Information ===" 
112- nvidia-smi --query-gpu=name,memory.total,compute_cap,driver_version --format=csv
113- echo "" 
114- 
115- echo "=== CUDA Samples Test ===" 
116- if [ -d "/usr/local/cuda/samples"  ]; then
117-     echo "CUDA samples directory found" 
118- else
119-     echo "CUDA samples not found - this is normal for newer CUDA versions" 
120- fi
121- 
122- echo "=== Environment Variables ===" 
123- echo "CUDA_HOME: $CUDA_HOME" 
124- echo "PATH: $PATH" 
125- echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH" 
126- echo "" 
127- 
128- echo "=== Build Test ===" 
129- cd /tmp
130- cat > test.cu << 'CUDA_EOF' 
131- # include <cuda_runtime.h>
132- # include <stdio.h>
133- 
134- __global__ void hello() {
135-     printf("Hello from GPU thread %d!\n " , threadIdx.x);
136- }
137- 
138- int main() {
139-     printf("CUDA Test Program\n " );
140-     hello<<<1, 5>>>();
141-     cudaDeviceSynchronize();
142-     printf("GPU kernel completed!\n " );
143-     return 0;
144- }
145- CUDA_EOF
146- 
147- echo "Compiling test CUDA program..." 
148- if nvcc -o test test.cu; then
149-     echo "✓ Compilation successful" 
150-     echo "Running test program:" 
151-     ./test
152-     echo "✓ CUDA environment is working correctly!" 
153- else
154-     echo "✗ Compilation failed" 
155-     exit 1
156- fi
157- 
158- rm -f test test.cu
159- echo "" 
160- echo "=== All tests completed ===" 
161- EOF
85+ RUN  printf '#!/bin/bash\n \ 
86+ echo "=== GPU Programming 101 - CUDA Environment Test ==="\n \ 
87+ echo "Date: $(date)"\n \ 
88+ echo ""\n \ 
89+ \n \
90+ echo "=== CUDA Compiler ==="\n \ 
91+ nvcc --version\n \ 
92+ echo ""\n \ 
93+ \n \
94+ echo "=== GPU Information ==="\n \ 
95+ if nvidia-smi --query-gpu=name,memory.total,compute_cap,driver_version --format=csv 2>/dev/null; then\n \ 
96+     echo "GPU detected successfully"\n \ 
97+ else\n \ 
98+     echo "No GPU detected or nvidia-smi not available"\n \ 
99+ fi\n \ 
100+ echo ""\n \ 
101+ \n \
102+ echo "=== Environment Variables ==="\n \ 
103+ echo "CUDA_HOME: $CUDA_HOME"\n \ 
104+ echo "PATH: $PATH"\n \ 
105+ echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"\n \ 
106+ echo ""\n \ 
107+ \n \
108+ echo "=== Build Test ==="\n \ 
109+ cd /tmp\n \ 
110+ cat > test.cu << ' "'" 'CUDA_EOF' "'" '\n \ 
111+ #include <cuda_runtime.h>\n \ 
112+ #include <stdio.h>\n \ 
113+ \n \
114+ __global__ void hello() {\n \ 
115+     printf("Hello from GPU thread %%d!\\ n", threadIdx.x);\n \ 
116+ }\n \ 
117+ \n \
118+ int main() {\n \ 
119+     printf("CUDA Test Program\\ n");\n \ 
120+     \n \ 
121+     int deviceCount;\n \ 
122+     cudaError_t error = cudaGetDeviceCount(&deviceCount);\n \ 
123+     \n \ 
124+     if (error != cudaSuccess) {\n \ 
125+         printf("CUDA Error: %%s\\ n", cudaGetErrorString(error));\n \ 
126+         printf("No CUDA-capable devices found\\ n");\n \ 
127+         return 0;\n \ 
128+     }\n \ 
129+     \n \ 
130+     printf("Found %%d CUDA device(s)\\ n", deviceCount);\n \ 
131+     hello<<<1, 5>>>();\n \ 
132+     cudaDeviceSynchronize();\n \ 
133+     printf("GPU kernel completed!\\ n");\n \ 
134+     return 0;\n \ 
135+ }\n \ 
136+ CUDA_EOF\n \ 
137+ \n \
138+ echo "Compiling test CUDA program..."\n \ 
139+ if nvcc -o test test.cu; then\n \ 
140+     echo "✓ Compilation successful"\n \ 
141+     echo "Running test program:"\n \ 
142+     ./test\n \ 
143+     echo "✓ CUDA environment is working correctly!"\n \ 
144+ else\n \ 
145+     echo "✗ Compilation failed"\n \ 
146+     exit 1\n \ 
147+ fi\n \ 
148+ \n \
149+ rm -f test test.cu\n \ 
150+ echo ""\n \ 
151+ echo "=== All tests completed ==="\n '  > /workspace/test-gpu.sh
162152
163153RUN  chmod +x /workspace/test-gpu.sh
164154
165- #  Install additional  CUDA samples and utilities 
155+ #  Install CUDA samples for learning  and reference 
166156RUN  cd /workspace && \
167157    git clone https://github.com/NVIDIA/cuda-samples.git && \
168158    cd cuda-samples && \
169159    git checkout v12.9
170160
171- #  Create jupyter kernel for CUDA (for notebooks)
172- RUN  python3 -m ipykernel install --name cuda-kernel --display-name "CUDA Python" 
173- 
174- #  Expose Jupyter port
175- EXPOSE  8888
176- 
177161#  Default command
178162CMD  ["/bin/bash" ]
179163
180- #  Health check to verify GPU access
164+ #  Health check to verify GPU access (will only work when GPU is available) 
181165HEALTHCHECK  --interval=30s --timeout=10s --start-period=5s --retries=3 \
182-     CMD  nvidia-smi  > /dev/null 2>&1 || exit 1
166+     CMD  nvcc --version  > /dev/null 2>&1 || exit 1
0 commit comments