This commit is contained in:
Oleg Sheynin 2024-06-04 19:14:01 +00:00
parent ae5b2ca565
commit b87224da5b
11 changed files with 1696 additions and 9 deletions

14
.gitignore vendored
View File

@ -2,13 +2,13 @@
**/.cache
**/workspaces
**/user-settings
fastbook
*.jpg*
*.JPG
*.png
*.gif
*.jpeg
*.img
#fastbook
# *.jpg*
# *.JPG
# *.png
# *.gif
# *.jpeg*
# *.img
.Trash*
*pkl
data

2
fastai/.env Normal file
View File

@ -0,0 +1,2 @@
ROOT_DIR=/opt/jupyter_gpu/fastai
JUPYTER_PORT=7777

32
fastai/Dockerfile Normal file
View File

@ -0,0 +1,32 @@
# -------------------------------------------------------
# Relies on JUPYTER_PORT being set in docker-compose.yml
# -------------------------------------------------------
FROM pytorch/pytorch:latest
# RUN useradd -m -s /bin/bash oleg
# Install packages
# --- this version of jupyter is required to work with the widgets
RUN pip install jupyterlab==3.6.7
#
RUN pip install ipywidgets
RUN pip install pandas numpy plotly
#
RUN pip install fastbook
# Install additional applications
RUN apt update
RUN apt-get install graphviz -y
# Set environment variables, etc.
#ENV MY_ENV_VAR=myvalue
# Set the working directory
WORKDIR /workspace
# Expose the port for JupyterLab
EXPOSE ${JUPYTER_PORT}
# Command to run JupyterLab
CMD ["jupyter-lab", "--ip=0.0.0.0", "--port=7777", "--no-browser", "--allow-root", "--NotebookApp.token=''"]

24
fastai/docker-compose.yml Normal file
View File

@ -0,0 +1,24 @@
version: '3.8'
#==================================================
# Relies on the file `.env` content for varables:
# ROOT_DIR
# JUPYTER_PORT
#==================================================
services:
jupyter:
build: ${ROOT_DIR}
image: cvtt/fastai:v0.0.1
container_name: fastai_jupyter
runtime: nvidia
environment:
- JUPYTER_ENABLE_LAB=yes
volumes:
- ${ROOT_DIR}/notebooks:/workspace
- ${ROOT_DIR}/jupyter_settings/user-settings:/root/.jupyter/lab/user-settings
- ${ROOT_DIR}/jupyter_settings/workspaces:/root/.jupyter/lab/workspaces
- ${ROOT_DIR}/.cache/torch:/root/.cache/torch
# - /opt/jupyter_gpu/data:/workspace/data
ports:
- "${JUPYTER_PORT}:${JUPYTER_PORT}"
shm_size: "8gb"

2
fastai/notebooks/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
bears
*.jpg

View File

@ -0,0 +1,192 @@
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "6b269e64-be58-43b5-ad60-0fbd1d37861a",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CUDA is available. Number of GPUs: 1\n",
"GPU Name: NVIDIA GeForce RTX 3060\n"
]
}
],
"source": [
"import torch\n",
"\n",
"# Check if CUDA is available\n",
"if torch.cuda.is_available():\n",
" print(f\"CUDA is available. Number of GPUs: {torch.cuda.device_count()}\")\n",
" print(f\"GPU Name: {torch.cuda.get_device_name(0)}\")\n",
"else:\n",
" print(\"CUDA is not available. No GPU detected.\")\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "97906ea2-b284-4966-9c11-b8629f053815",
"metadata": {},
"outputs": [],
"source": [
"import plotly"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "7313a620-a0eb-4207-a12a-90aeee3cd980",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0]'"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import sys\n",
"sys.version"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "95d9a2e6-3464-4dbe-9a97-0c2d5eb34193",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"environ{'PATH': '/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',\n",
" 'HOSTNAME': '1fc69c311e22',\n",
" 'JUPYTER_ENABLE_LAB': 'yes',\n",
" 'NVIDIA_VISIBLE_DEVICES': 'all',\n",
" 'NVIDIA_DRIVER_CAPABILITIES': 'compute,utility',\n",
" 'LD_LIBRARY_PATH': '/usr/local/nvidia/lib:/usr/local/nvidia/lib64',\n",
" 'PYTORCH_VERSION': '2.2.1',\n",
" 'HOME': '/root',\n",
" 'LC_CTYPE': 'C.UTF-8',\n",
" 'JPY_SESSION_NAME': '/workspace/oleg/Testing GPU.ipynb',\n",
" 'JPY_PARENT_PID': '1',\n",
" 'PYDEVD_USE_FRAME_EVAL': 'NO',\n",
" 'TERM': 'xterm-color',\n",
" 'CLICOLOR': '1',\n",
" 'FORCE_COLOR': '1',\n",
" 'CLICOLOR_FORCE': '1',\n",
" 'PAGER': 'cat',\n",
" 'GIT_PAGER': 'cat',\n",
" 'MPLBACKEND': 'module://matplotlib_inline.backend_inline',\n",
" 'CUDA_MODULE_LOADING': 'LAZY'}"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import os\n",
"import pandas as pd\n",
"import matplotlib\n",
"os.environ"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "eb38de31-fc19-4515-b08d-9cd7607ea958",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "75642bda0eed47598e340b8c1766949a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(IntSlider(value=5, description='x', max=10), Output()), _dom_classes=('widget-interact',…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Done\n"
]
}
],
"source": [
"import ipywidgets\n",
"from ipywidgets import interact, IntSlider\n",
"\n",
"def f(x):\n",
" return x\n",
"\n",
"interact(f, x=IntSlider(min=0, max=10, step=1, value=5))\n",
"print(\"Done\")\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "f46e46a7-9b57-44aa-9bc9-dcbcf643bc88",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"jupyter-events==0.10.0\n",
"jupyter-lsp==2.2.5\n",
"jupyter_client==8.6.2\n",
"jupyter_core==5.7.2\n",
"jupyter_server==2.14.1\n",
"jupyter_server_terminals==0.5.3\n",
"jupyterlab==4.2.1\n",
"jupyterlab_pygments==0.3.0\n",
"jupyterlab_server==2.27.2\n",
"jupyterlab_widgets==3.0.11\n"
]
}
],
"source": [
"!pip freeze | grep jupyter"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.13"
}
},
"nbformat": 4,
"nbformat_minor": 5
}

File diff suppressed because one or more lines are too long

@ -0,0 +1 @@
Subproject commit 054cd8a62c7b6c11f0c36265149ccbaf95d91034

View File

@ -100,6 +100,72 @@
"import matplotlib\n",
"os.environ"
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "eb38de31-fc19-4515-b08d-9cd7607ea958",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "75642bda0eed47598e340b8c1766949a",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"interactive(children=(IntSlider(value=5, description='x', max=10), Output()), _dom_classes=('widget-interact',…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"Done\n"
]
}
],
"source": [
"import ipywidgets\n",
"from ipywidgets import interact, IntSlider\n",
"\n",
"def f(x):\n",
" return x\n",
"\n",
"interact(f, x=IntSlider(min=0, max=10, step=1, value=5))\n",
"print(\"Done\")\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "f46e46a7-9b57-44aa-9bc9-dcbcf643bc88",
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"jupyter-events==0.10.0\n",
"jupyter-lsp==2.2.5\n",
"jupyter_client==8.6.2\n",
"jupyter_core==5.7.2\n",
"jupyter_server==2.14.1\n",
"jupyter_server_terminals==0.5.3\n",
"jupyterlab==4.2.1\n",
"jupyterlab_pygments==0.3.0\n",
"jupyterlab_server==2.27.2\n",
"jupyterlab_widgets==3.0.11\n"
]
}
],
"source": [
"!pip freeze | grep jupyter"
]
}
],
"metadata": {

View File

@ -1,2 +1,2 @@
ROOT_DIR=/opt/jupyter_gpu/test
JUPYTER_PORT=7777
JUPYTER_PORT=7778

View File

@ -21,5 +21,5 @@ WORKDIR /workspace
EXPOSE ${JUPYTER_PORT}
# Command to run JupyterLab
CMD ["sh", "-c", "jupyter-lab --ip=0.0.0.0 --port=7777 --no-browser --allow-root --NotebookApp.token=''"]
CMD ["sh", "-c", "jupyter-lab --ip=0.0.0.0 --port=7778 --no-browser --allow-root --NotebookApp.token=''"]