|
#!/bin/bash |
|
|
|
|
|
handle_error() { |
|
echo "Error: $1" |
|
exit 1 |
|
} |
|
|
|
|
|
if [ ! -d "/data" ]; then |
|
mkdir -p /data || handle_error "Could not create /data directory" |
|
echo "/data directory created for persistent storage" |
|
fi |
|
|
|
|
|
if [ ! -w "/data" ]; then |
|
echo "Warning: No write permissions for /data. Some data may not be persistent." |
|
fi |
|
|
|
|
|
if [ -z "$JUPYTER_TOKEN" ]; then |
|
export JUPYTER_TOKEN=${AUX_TOKEN:-} |
|
fi |
|
|
|
|
|
if [ -z "$JUPYTER_TOKEN" ]; then |
|
handle_error "JupyterLab token is empty" |
|
fi |
|
|
|
|
|
if command -v nvidia-smi &> /dev/null; then |
|
echo "GPU detected. Configuring environment for GPU usage." |
|
export NVIDIA_VISIBLE_DEVICES=all |
|
export NVIDIA_DRIVER_CAPABILITIES=compute,utility |
|
else |
|
echo "No GPU detected. CPU will be used." |
|
fi |
|
|
|
|
|
jupyter lab --ip=0.0.0.0 --port=${JUPYTERLAB_PORT} --no-browser --allow-root \ |
|
--NotebookApp.token=${JUPYTER_TOKEN} \ |
|
--notebook-dir=/data & |
|
|
|
|
|
nginx -g "daemon off;" || handle_error "Failed to start Nginx" |