Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small improvements: GPU detection, relative bind mounts, bind mounts with spaces #9

Merged
merged 5 commits into from
Apr 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
only add gpu flags if gpu is found
fixes #17
  • Loading branch information
lreiher committed Apr 2, 2024
commit 42a2d062cf6fe6fb533ef472d90cf49de218f00f
2 changes: 1 addition & 1 deletion docker-run-cli/pyproject.toml
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ classifiers = [
"Operating System :: POSIX :: Linux",
]
keywords = ["docker", "container"]
dependencies = []
dependencies = ["GPUtil~=1.4.0"]
requires-python = ">=3.7"

[project.optional-dependencies]
18 changes: 12 additions & 6 deletions docker-run-cli/src/docker_run/plugins/core.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,8 @@
import tempfile
from typing import Any, Dict, List

import GPUtil

from docker_run.utils import log, runCommand
from docker_run.plugins.plugin import Plugin

@@ -78,12 +80,16 @@ def localeFlags(cls) -> List[str]:

@classmethod
def gpuSupportFlags(cls) -> List[str]:
if cls.ARCH == "x86_64":
return ["--gpus all"]
elif cls.ARCH == "aarch64" and cls.OS == "Linux":
return ["--runtime nvidia"]
if len(GPUtil.getGPUs()) > 0:
if cls.ARCH == "x86_64":
return ["--gpus all"]
elif cls.ARCH == "aarch64" and cls.OS == "Linux":
return ["--runtime nvidia"]
else:
log(f"GPU not supported by `docker-run` on {cls.OS} with {cls.ARCH} architecture")
return []
else:
log(f"GPU not supported by `docker-run` on {cls.OS} with {cls.ARCH} architecture")
log(f"No GPU detected")
return []

@classmethod
@@ -92,7 +98,7 @@ def x11GuiForwardingFlags(cls, docker_network: str = "bridge") -> List[str]:
display = os.environ.get("DISPLAY")
if display is None:
return []

if cls.OS == "Darwin":
runCommand(f"xhost +local:")