merge devgpu
This commit is contained in:
85
README.md
85
README.md
@@ -63,4 +63,87 @@ docker buildx build -t hotwa/notebook:latest . -f Dockerfile
|
||||
- [openshift/source-to-image](https://github.com/openshift/source-to-image) -
|
||||
A tool for building artifacts from source code and injecting them into docker images
|
||||
- [jupyter-on-openshift/jupyter-notebooks](https://github.com/jupyter-on-openshift/jupyter-notebooks) -
|
||||
OpenShift compatible S2I builder for basic notebook images
|
||||
OpenShift compatible S2I builder for basic notebook images
|
||||
|
||||
## nvidia-container-toolkit add
|
||||
|
||||
参考了 llama [容器部署](https://hub.docker.com/r/ollama/ollama)
|
||||
|
||||
```shell
|
||||
curl -fsSL https://nvidia.github.io/libnvidia-container/gpgkey \
|
||||
| sudo gpg --dearmor -o /usr/share/keyrings/nvidia-container-toolkit-keyring.gpg
|
||||
curl -s -L https://nvidia.github.io/libnvidia-container/stable/deb/nvidia-container-toolkit.list \
|
||||
| sed 's#deb https://#deb [signed-by=/usr/share/keyrings/nvidia-container-toolkit-keyring.gpg] https://#g' \
|
||||
| sudo tee /etc/apt/sources.list.d/nvidia-container-toolkit.list
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y nvidia-container-toolkit
|
||||
```
|
||||
|
||||
Configure Docker to use Nvidia driver
|
||||
|
||||
```shell
|
||||
sudo nvidia-ctk runtime configure --runtime=docker
|
||||
sudo systemctl restart docker
|
||||
```
|
||||
|
||||
配置完成之后:
|
||||
|
||||
```shell
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
在jupyterhub_config.py中添加:这样jupyterhub的容器启动镜像就可以使用宿主机的显卡了
|
||||
|
||||
```python
|
||||
# GPU 和网络配置
|
||||
c.DockerSpawner.extra_host_config = {
|
||||
#'network_mode': 'host',
|
||||
'runtime': 'nvidia'
|
||||
}
|
||||
c.DockerSpawner.environment = {
|
||||
'NVIDIA_DRIVER_CAPABILITIES': 'compute,utility',
|
||||
'NVIDIA_VISIBLE_DEVICES': 'all'
|
||||
}
|
||||
```
|
||||
|
||||
## 清除卷
|
||||
|
||||
|
||||
```shell
|
||||
docker volume ls
|
||||
docker-compose down
|
||||
docker rm <container_name_or_id>
|
||||
docker volume rm basic-example_jupyterhub-data
|
||||
docker volume rm docker-jupyterhub_jupyterhub-data
|
||||
docker volume rm jupyterhub-user-admin
|
||||
```
|
||||
|
||||
## 构建
|
||||
|
||||
构建基础notebook镜像
|
||||
|
||||
```shell
|
||||
docker buildx build -t hotwa/notebook:latest -f Dockerfile.base-notebook . --load
|
||||
```
|
||||
|
||||
构建jupyterhub镜像
|
||||
|
||||
```shell
|
||||
docker compose build
|
||||
```
|
||||
|
||||
## 推送镜像至阿里云私有仓库
|
||||
|
||||
```shell
|
||||
docker login --username=ze.ga@qq.com registry.cn-hangzhou.aliyuncs.com
|
||||
# 重命名
|
||||
docker tag 2ad3860183ce registry.cn-hangzhou.aliyuncs.com/hotwa/jupyterhub:latest
|
||||
docker tag ddf815cbaa9b registry.cn-hangzhou.aliyuncs.com/hotwa/notebook:latest
|
||||
# 推送
|
||||
docker login --username=ze.ga@qq.com registry.cn-hangzhou.aliyuncs.com
|
||||
docker push registry.cn-hangzhou.aliyuncs.com/hotwa/jupyterhub:latest
|
||||
docker push registry.cn-hangzhou.aliyuncs.com/hotwa/notebook:latest
|
||||
# 拉取
|
||||
docker pull registry.cn-hangzhou.aliyuncs.com/hotwa/jupyterhub:latest
|
||||
docker pull registry.cn-hangzhou.aliyuncs.com/hotwa/notebook:latest
|
||||
```
|
||||
Reference in New Issue
Block a user