Skip to content

Commit 12b15ea

Browse files
committed
Updates to CUDA 11.8 / .NET 9 fixes
1 parent 7d37781 commit 12b15ea

8 files changed

Lines changed: 114 additions & 106 deletions

File tree

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"CPAI",
1111
"createallsubdirs",
1212
"CTYPE",
13+
"cuda",
1314
"cudnn",
1415
"deadsnakes",
1516
"discardable",

Docker/Docker build notes.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Managing disk usage
22

3-
Docker can be a space hog. Two things can be done to reclaim space
3+
Docker can be a space hog. Three things can be done to reclaim space
44

55
1. Install the "Disk Usage" docker desktop extension and use it to remove build cache, hanging images, or anything else you don't need
66

@@ -16,9 +16,10 @@ Docker can be a space hog. Two things can be done to reclaim space
1616
- `compact vdisk`
1717
- `exit`
1818

19-
Your docker VM disk should now be as compact as it can get
19+
Your docker VM disk should, hopefully, be a little smaller
20+
21+
3. Use the PowerShell script `devops\utils\compact_wsl_disks.ps1` in the CodeProject.AI-Server project
2022

2123
# Permissions issues
2224

2325
1. `docker login --username` - this will prompt you for your password. Enter your docker hub password.
24-
2. `docker login --username` - same, but instead of your docker hub password, use a

Docker/Dockerfile

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,9 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \
133133
# .NET -------------------------------------------------------------------------
134134

135135
# Update packages and install .NET
136-
RUN wget "https://packages.microsoft.com/config/ubuntu/${UBUNTU_VERSION}/packages-microsoft-prod.deb" \
137-
-O packages-microsoft-prod.deb --no-check-certificate && \
138-
dpkg -i packages-microsoft-prod.deb && \
139-
rm packages-microsoft-prod.deb && \
140-
apt update && apt install aspnetcore-runtime-$DOTNET_VERSION -y > /dev/null
136+
RUN apt install software-properties-common -y && \
137+
add-apt-repository ppa:dotnet/backports -y && \
138+
apt-get update && apt-get install aspnetcore-runtime-$DOTNET_VERSION -y > /dev/null
141139

142140

143141
# Setup Python ----------------------------------------------------------------

Docker/Dockerfile-Arm64

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -130,17 +130,22 @@ RUN apt-get update -y && \
130130
# Update packages and install .NET
131131

132132
# See https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#scripted-install
133-
RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
134-
RUN chmod +x ./dotnet-install.sh
133+
# RUN wget https://dot.net/v1/dotnet-install.sh -O dotnet-install.sh
134+
# RUN chmod +x ./dotnet-install.sh
135135

136136
# Install .NET. For just the runtime use "--channel $DOTNET_VERSION --runtime aspnetcore"
137-
RUN ./dotnet-install.sh --channel $DOTNET_VERSION --runtime aspnetcore
137+
# RUN ./dotnet-install.sh --channel $DOTNET_VERSION --runtime aspnetcore
138138

139139
# The install script is for CI/CD and doesn't actually register .NET. So add
140140
# link and env variable
141-
RUN ln -fs $HOME/.dotnet/dotnet /usr/local/bin/dotnet
142-
RUN echo 'export DOTNET_ROOT=~/.dotnet' >> $HOME/.bashrc
143-
RUN echo 'export PATH=$PATH:$DOTNET_ROOT' >> $HOME/.bashrc
141+
# RUN ln -fs $HOME/.dotnet/dotnet /usr/local/bin/dotnet
142+
# RUN echo 'export DOTNET_ROOT=~/.dotnet' >> $HOME/.bashrc
143+
# RUN echo 'export PATH=$PATH:$DOTNET_ROOT' >> $HOME/.bashrc
144+
145+
# Update packages and install .NET
146+
RUN apt install software-properties-common -y && \
147+
add-apt-repository ppa:dotnet/backports -y && \
148+
apt-get update && apt-get install aspnetcore-runtime-$DOTNET_VERSION -y > /dev/null
144149

145150

146151
# Setup Python ----------------------------------------------------------------
@@ -286,7 +291,6 @@ WORKDIR /src
286291
# This enables us to have a modulesettings for inside a docker image, and module
287292
# settings for modules outside the docker image.
288293

289-
290294
COPY [ "/${MODULES_REPO_NAME}/CodeProject.AI-FaceProcessing/", "/app/publish/preinstalled-modules/FaceProcessing"]
291295
RUN mv -f "/app/publish/preinstalled-modules/FaceProcessing/modulesettings.docker.build.json" \
292296
"/app/publish/preinstalled-modules/FaceProcessing/modulesettings.docker.json" && \
@@ -317,7 +321,7 @@ COPY ["/${REPO_NAME}/.env", "/app/publish/.env"]
317321
RUN rm -rf /app/publish/SDK/Python/__pycache__ \
318322
mkdir /app/publish/runtimes
319323

320-
# END REVIEW ===================================================================
324+
# END REVIEW ==================================================================
321325

322326

323327
# CREATE THE FINAL IMAGE ======================================================
@@ -341,9 +345,9 @@ COPY --from=build /app/publish .
341345
# --compile and --global-option now deprecated, the CLFAGS to nothing, but the --no-cache-dir does help
342346

343347
RUN python3.8 -m pip --no-cache-dir install \
344-
-r /app/preinstalled-modules/ObjectDetectionYOLOv5-6.2/requirements.linux.arm64.txt \
345-
-r /app/preinstalled-modules/FaceProcessing/requirements.linux.arm64.txt \
346-
-r /app/SDK/Python/requirements.txt
348+
-r "/app/preinstalled-modules/ObjectDetectionYOLOv5-6.2/requirements.linux.arm64.txt" \
349+
-r "/app/preinstalled-modules/FaceProcessing/requirements.linux.arm64.txt" \
350+
-r "/app/SDK/Python/requirements.txt"
347351

348352
RUN python3.9 -m pip --no-cache-dir install \
349353
-r /app/SDK/Python/requirements.txt
@@ -354,9 +358,9 @@ RUN python3.9 -m pip --no-cache-dir install \
354358
# on macOS.
355359
# We also make a .vscode folder so we have some bits in place if we wish to run
356360
# VSCode inside the container
357-
RUN mkdir --parents /etc/codeproject/ai && \
358-
mkdir --parents /app/downloads/modules /app/modules && \
359-
mkdir /app/.vscode
361+
RUN mkdir --parents "/etc/codeproject/ai" && \
362+
mkdir --parents "/app/downloads/modules" "/app/modules" && \
363+
mkdir "/app/.vscode"
360364

361365
# For debugging the live container using VS Code
362366
COPY [ "/${REPO_NAME}/.vscode/launch.docker.json", "/app/.vscode/launch.json" ]

Docker/Dockerfile-GPU-CUDA

Lines changed: 74 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
# is set in the build_docker script as the last param to the docker buildx command,
1313
# namely the "../..". This takes us from /Installers/Docker to /. and then this
1414
# image file proceeds
15-
#
16-
# BE AWARE: this cuDNN equipped build may lock up when two YOLO equipped modules
17-
# are installed on it. Without cuDNN, .NET ONNX runtime for GPU doesn't work.
15+
1816

1917
# INITIAL SETUP ===============================================================
2018

@@ -26,8 +24,7 @@ ARG DOTNET_VERSION=9.0
2624
ARG CPAI_VERSION
2725

2826
# CUDA_VERSION = 11.7.1-cudnn8, 11.8.0-cudnn8, 12.0.1-cudnn8, 12.2.2-cudnn8
29-
# or cuDNN free: 11.7.1, 12.3.1
30-
ARG CUDA_VERSION=11.7.1-cudnn8
27+
ARG CUDA_VERSION=12.2.2-cudnn8
3128
ARG CUDA_MAJOR=11
3229

3330
FROM nvidia/cuda:$CUDA_VERSION-runtime-ubuntu$UBUNTU_VERSION AS base
@@ -127,72 +124,77 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \
127124
\
128125
psmisc \
129126
\
130-
kmod \
131-
> /dev/null
132-
# libnvidia-compute-535 > /dev/null
133-
134-
# Not needed. Probably.
135-
# apt-utils
127+
kmod > /dev/null
136128

137129

138130
# .NET ------------------------------------------------------------------------
139131

140-
# Update packages and install NET
141-
RUN wget "https://packages.microsoft.com/config/ubuntu/${UBUNTU_VERSION}/packages-microsoft-prod.deb" \
142-
-O packages-microsoft-prod.deb --no-check-certificate && \
143-
dpkg -i packages-microsoft-prod.deb && \
144-
rm packages-microsoft-prod.deb && \
145-
apt update && apt install aspnetcore-runtime-$DOTNET_VERSION -y > /dev/null
132+
# Update packages and install .NET
133+
RUN apt install software-properties-common -y && \
134+
add-apt-repository ppa:dotnet/backports -y && \
135+
apt-get update && apt-get install aspnetcore-runtime-$DOTNET_VERSION -y > /dev/null
146136

147137

148138
# Setup Python ----------------------------------------------------------------
149139

150-
RUN apt-get install software-properties-common -y && add-apt-repository ppa:deadsnakes/ppa -y
151-
152-
# This (currently) installs python3.8 as a dependency. It could be in the future
153-
# that a different version of python is installed instead, in which case we may
154-
# need to pin the installed python version.
155-
RUN apt-get install python3-pip -y && apt-get install python3-apt -y
156-
157-
# Install Python3.8, distutils and dev tools (so packages can be built if needed)
158-
# and pip install so we can install python packages
159-
RUN apt-get install python3.8 -y && \
160-
apt-get install python3.8-distutils -y && \
161-
apt-get install python3.8-dev -y && \
162-
python3.8 -m pip install --upgrade setuptools && \
163-
python3.8 -m pip install --upgrade pip
164-
165-
# install virtual env tools
166-
RUN apt install python3-pip python3-setuptools python3.8-venv -y && \
167-
python3.8 -m pip install virtualenv virtualenvwrapper
168-
169-
# Install Python3.9, distutils and dev tools (so packages can be built if needed)
170-
# and pip install so we can install python packages. We don't need this for the
171-
# built in modules, but we know we have downloadable modules that could use Python3.9
172-
# so we preempt the need.
173-
RUN apt-get install python3.9 -y && \
174-
apt-get install python3.9-distutils -y && \
175-
apt-get install python3.9-dev -y && \
176-
python3.9 -m pip install --upgrade setuptools && \
177-
python3.9 -m pip install --upgrade pip
178-
179-
#RUN apt python3.9-venv -y
180-
RUN apt install python3.9-venv -y && \
181-
python3.9 -m pip install virtualenv virtualenvwrapper
182-
183-
# Install Python3.11, distutils and dev tools (so packages can be built if needed)
184-
# and pip install so we can install python packages. We don't need this for the
185-
# built in modules, but we know we have downloadable modules that could use Python3.9
186-
# so we preempt the need.
187-
RUN apt-get install python3.11 -y && \
188-
apt-get install python3.11-distutils -y && \
189-
apt-get install python3.11-dev -y && \
190-
python3.11 -m pip install --upgrade setuptools && \
191-
python3.11 -m pip install --upgrade pip
192-
193-
#RUN apt python3.11-venv -y
194-
RUN apt install python3.11-venv -y && \
195-
python3.11 -m pip install virtualenv virtualenvwrapper
140+
# Combining all these together into a single layer
141+
# 1. Add deadsnakes repo
142+
# 2. Install pip for python3, python3-apt and python3-setuptools
143+
# Note that this (currently) installs python3.8 as a dependency. It could be
144+
# in the future that a different version of python is installed instead, in
145+
# which case we may need to pin the installed python version.
146+
# 3. Install Python 3.8 as well as dev and distutils so packages can be built
147+
# if needed, and venv for creating virtual environments
148+
# 4. Using the now installed Python 3.8, upgrade the python setuptools and dev
149+
# packages to the latest
150+
# 5. Install virtualenv virtualenvwrapper for python 3.8
151+
152+
RUN apt-get install software-properties-common -y && \
153+
add-apt-repository ppa:deadsnakes/ppa -y && \
154+
apt-get install -y --no-install-recommends \
155+
python3-pip \
156+
python3-apt \
157+
python3-setuptools && \
158+
apt-get install -y --no-install-recommends \
159+
python3.8 && \
160+
apt-get install -y --no-install-recommends \
161+
python3.8-distutils \
162+
python3.8-dev \
163+
python3.8-venv && \
164+
python3.8 -m pip install --upgrade setuptools && \
165+
python3.8 -m pip install --upgrade pip && \
166+
python3.8 -m pip install virtualenv virtualenvwrapper > /dev/null
167+
168+
# Python 3.9: Combining all these together into a single layer, but leveraging
169+
# the work done in Python 3.8:
170+
# 1. Install Python 3.9 as well as dev and distutils so packages can be built
171+
# if needed, and venv for creating virtual environments
172+
# 4. Using the now installed Python 3.8, upgrade the python setuptools and dev
173+
# packages to the latest
174+
# 5. Install virtualenv virtualenvwrapper for python 3.8
175+
176+
RUN apt-get install -y --no-install-recommends \
177+
python3.9 && \
178+
apt-get install -y --no-install-recommends \
179+
python3.9-distutils \
180+
python3.9-dev \
181+
python3.9-venv && \
182+
python3.9 -m pip install --upgrade setuptools && \
183+
python3.9 -m pip install --upgrade pip && \
184+
python3.9 -m pip install virtualenv virtualenvwrapper > /dev/null
185+
186+
# Same for Python3.11
187+
188+
RUN apt-get install -y --no-install-recommends \
189+
python3.11 && \
190+
apt-get install -y --no-install-recommends \
191+
python3.11-distutils \
192+
python3.11-dev \
193+
python3.11-venv && \
194+
python3.11 -m pip install --upgrade setuptools && \
195+
python3.11 -m pip install --upgrade pip && \
196+
python3.11 -m pip install virtualenv virtualenvwrapper > /dev/null
197+
196198

197199
# Build the .NET source in a separate, discardable build container --------------
198200

@@ -252,7 +254,6 @@ RUN dotnet publish ObjectDetectionYOLOv5Net.csproj -c Release --no-self-containe
252254
mv -f /app/publish/preinstalled-modules/ObjectDetectionYOLOv5Net/modulesettings.docker.build.json \
253255
/app/publish/preinstalled-modules/ObjectDetectionYOLOv5Net/modulesettings.docker.json > /dev/null
254256

255-
256257
# BEGIN REVIEW ================================================================
257258

258259
# REVIEW: [Matthew] This section should go in the "FROM base AS final" part, not
@@ -291,18 +292,21 @@ WORKDIR /src
291292

292293
COPY ["${MODULES_REPO_NAME}/CodeProject.AI-FaceProcessing/", "/app/publish/preinstalled-modules/FaceProcessing"]
293294
RUN mv -f /app/publish/preinstalled-modules/FaceProcessing/modulesettings.docker.build.json \
294-
/app/publish/preinstalled-modules/FaceProcessing/modulesettings.docker.json
295-
RUN rm -rf /app/publish/preinstalled-modules/FaceProcessing/intelligencelayer/__pycache__ && \
295+
/app/publish/preinstalled-modules/FaceProcessing/modulesettings.docker.json && \
296+
rm -rf /app/publish/preinstalled-modules/FaceProcessing/intelligencelayer/__pycache__ && \
297+
rm -rf /app/publish/preinstalled-modules/FaceProcessing/bin && \
296298
rm -f /app/publish/preinstalled-modules/FaceProcessing/*.zip \
297299
/app/publish/preinstalled-modules/FaceProcessing/package.bat \
298-
/app/publish/preinstalled-modules/FaceProcessing/*.pyprog
300+
/app/publish/preinstalled-modules/FaceProcessing/*.pyprog > /dev/null
299301

300302
COPY ["/${REPO_NAME}/modules/ObjectDetectionYOLOv5-6.2/", "/app/publish/preinstalled-modules/ObjectDetectionYOLOv5-6.2"]
301-
RUN mv -f "/app/publish/preinstalled-modules/ObjectDetectionYOLOv5-6.2/modulesettings.docker.build.gpu.json" "/app/publish/preinstalled-modules/ObjectDetectionYOLOv5-6.2/modulesettings.docker.json"
302-
RUN rm -rf /app/publish/preinstalled-modules/ObjectDetectionYOLOv5-6.2/__pycache__ && \
303+
RUN mv -f "/app/publish/preinstalled-modules/ObjectDetectionYOLOv5-6.2/modulesettings.docker.build.gpu.json" \
304+
"/app/publish/preinstalled-modules/ObjectDetectionYOLOv5-6.2/modulesettings.docker.json" && \
305+
rm -rf /app/publish/preinstalled-modules/ObjectDetectionYOLOv5-6.2/__pycache__ && \
306+
rm -rf /app/publish/preinstalled-modules/ObjectDetectionYOLOv5-6.2/bin && \
303307
rm -f /app/publish/preinstalled-modules/ObjectDetectionYOLOv5-6.2/*.zip \
304308
/app/publish/preinstalled-modules/ObjectDetectionYOLOv5-6.2/package.bat \
305-
/app/publish/preinstalled-modules/ObjectDetectionYOLOv5-6.2/*.pyprog
309+
/app/publish/preinstalled-modules/ObjectDetectionYOLOv5-6.2/*.pyprog > /dev/null
306310

307311
# SDK and install scripts
308312
COPY ["/${REPO_NAME}/src/SDK/Python", "/app/publish/SDK/Python"]

Docker/Dockerfile-GPU-CUDA10_2

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,6 @@ EXPOSE 32168/udp
7878

7979
# Add some labels to the container --------------------------------------------
8080

81-
ARG VERSION
82-
ENV VERSION=${VERSION}
83-
8481
LABEL "Application"="CodeProject.AI Server"
8582
LABEL "Publisher"="CodeProject Solutions Inc"
8683
LABEL "Version"="${CPAI_VERSION}"
@@ -137,12 +134,13 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \
137134
# .NET ------------------------------------------------------------------------
138135

139136
# Update packages and install NET
140-
RUN wget "https://packages.microsoft.com/config/ubuntu/$UBUNTU_VERSION/packages-microsoft-prod.deb" \
137+
RUN wget "https://packages.microsoft.com/config/ubuntu/${UBUNTU_VERSION}/packages-microsoft-prod.deb" \
141138
-O packages-microsoft-prod.deb --no-check-certificate && \
142139
dpkg -i packages-microsoft-prod.deb && \
143140
rm packages-microsoft-prod.deb && \
144141
apt update && apt install aspnetcore-runtime-$DOTNET_VERSION -y > /dev/null
145142

143+
146144
# Setup Python ----------------------------------------------------------------
147145

148146
RUN apt-get install software-properties-common -y && add-apt-repository ppa:deadsnakes/ppa -y

0 commit comments

Comments
 (0)