Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Public exercise material
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
aia02506
Public exercise material
Commits
3402c860
Commit
3402c860
authored
2 years ago
by
abda
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
9a3e9c98
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Chapter10/env02506.sh
+39
-0
39 additions, 0 deletions
Chapter10/env02506.sh
with
39 additions
and
0 deletions
Chapter10/env02506.sh
0 → 100644
+
39
−
0
View file @
3402c860
#!/bin/bash
# Simple init script for Python on DTU HPC
# Patrick M. Jensen, patmjen@dtu.dk, 2022
# Configuration
# This is what you should change for your setup
VENV_NAME
=
env02506
# Name of your virtualenv (default: venv)
VENV_DIR
=
.
# Where to store your virtualenv (default: current directory)
PYTHON_VERSION
=
3.9.14
# Python version (default: 3.9.14)
CUDA_VERSION
=
11.6
# CUDA version (default: 11.6)
# Load modules
module load python3/
$PYTHON_VERSION
module load
$(
module avail
-o
modulepath
-t
-C
"python-
${
PYTHON_VERSION
}
"
|
grep
"numpy/"
)
module load
$(
module avail
-o
modulepath
-t
-C
"python-
${
PYTHON_VERSION
}
"
|
grep
"scipy/"
)
module load
$(
module avail
-o
modulepath
-t
-C
"python-
${
PYTHON_VERSION
}
"
|
grep
"matplotlib/"
)
module load
$(
module avail
-o
modulepath
-t
-C
"python-
${
PYTHON_VERSION
}
"
|
grep
"pandas/"
)
module load cuda/
$CUDA_VERSION
CUDNN_MOD
=
$(
module avail
-o
modulepath
-t
cudnn |
grep
"cuda-
${
CUDA_VERSION
}
"
|
sort
|
tail
-n1
)
if
[[
${
CUDNN_MOD
}
]]
then
module load
${
CUDNN_MOD
}
fi
# Create virtualenv if needed and activate it
if
[
!
-d
"
${
VENV_DIR
}
/
${
VENV_NAME
}
"
]
then
echo
INFO: Did not find virtualenv. Creating...
virtualenv
"
${
VENV_DIR
}
/
${
VENV_NAME
}
"
fi
source
"
${
VENV_DIR
}
/
${
VENV_NAME
}
/bin/activate"
# Select least used GPU if any are available
if
command
-v
nvidia-smi &> /dev/null
then
export
CUDA_VISIBLE_DEVICES
=
$(
nvidia-smi
--query-gpu
=
memory.used,utilization.gpu,utilization.gpu,index
--format
=
csv,noheader,nounits |
sort
-V
|
awk
'{print $NF}'
|
head
-n1
)
echo
CUDA_VISIBLE_DEVICES
=
${
CUDA_VISIBLE_DEVICES
}
fi
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment