Skip to content

Commit

Permalink
Mount cuda libray into the container; added the option --privileged t…
Browse files Browse the repository at this point in the history
…o podman; changed /bin/bash in login mode for docker/podman exec
  • Loading branch information
Shuwei Ye authored and Shuwei Ye committed May 31, 2024
1 parent c5c8120 commit d163a1c
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions run-ml_container.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
# coding: utf-8
# version=2024-04-16-r01
# version=2024-05-31-r01
# author: Shuwei Ye <[email protected]>
"true" '''\'
myScript="${BASH_SOURCE:-$0}"
Expand Down Expand Up @@ -514,10 +514,11 @@ def create_container(contCmd, contName, dockerPath, bindOpt, force=False):
secOpt = ""
if contCmd == "podman":
lsCmd = "%s run -it --rm %s ls / | tail -1" % (contCmd, dockerPath)
out = run_shellCmd(lsCmd, exitOnFailure=False)
if out.find("Operation not permitted") >= 0:
secOpt = "--security-opt seccomp=unconfined"
# lsCmd = "%s run -it --rm %s ls / | tail -1" % (contCmd, dockerPath)
# out = run_shellCmd(lsCmd, exitOnFailure=False)
# if out.find("Operation not permitted") >= 0:
# secOpt = "--security-opt seccomp=unconfined"
secOpt = "--privileged"
pwd = os.getcwd()
createOpt = "-it -v %s:%s -w %s %s %s %s" % (
Expand Down Expand Up @@ -593,7 +594,7 @@ if [[ $# -eq 1 && "$1" =~ ^[Jj]upyter$ ]]; then
gid=$(id -g)
runCmd="$contCmd exec -it -u ${uid}:${gid} -e USER=$USER $contName jupyter lab --ip 0.0.0.0"
else
runCmd="$contCmd exec -it $contName /bin/bash"
runCmd="$contCmd exec -it $contName /bin/bash -l"
fi
echo -e "\\n$runCmd\\n"
Expand Down Expand Up @@ -772,6 +773,8 @@ def setup(args):
bindOpt = '--device=' + ','.join(devices)
else:
bindOpt = '--gpus all'
if os.path.exists("/usr/lib64/libcuda.so") and os.path.exists("/usr/lib64/libcuda.so.1"):
bindOpt += " -v /usr/lib64/libcuda.so:/usr/local/nvidia/lib64/libcuda.so -v /usr/lib64/libcuda.so.1:/usr/local/nvidia/lib64/libcuda.so.1"
for path in volumes:
if path.find(':') > 0:
Expand Down

0 comments on commit d163a1c

Please sign in to comment.