-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding GPU feature and some dependent tools
- Loading branch information
Showing
7 changed files
with
337 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,8 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT license. | ||
|
||
from .gpu import Gpu | ||
from .serial_console import SerialConsole | ||
from .startstop import StartStop | ||
|
||
__all__ = ["SerialConsole", "StartStop"] | ||
__all__ = ["Gpu", "SerialConsole", "StartStop"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# Copyright (c) Microsoft Corporation. | ||
# Licensed under the MIT license. | ||
|
||
from enum import Enum | ||
from typing import Any | ||
|
||
from lisa.feature import Feature | ||
from lisa.operating_system import Linux, Redhat, Ubuntu | ||
from lisa.tools import Uname, Wget | ||
from lisa.util import LisaException | ||
|
||
FEATURE_NAME_GPU = "Gpu" | ||
|
||
|
||
class compute_sdk(Enum): | ||
GRID = 0 | ||
CUDA = 1 | ||
|
||
|
||
class Gpu(Feature): | ||
def __init__(self, node: Any, platform: Any) -> None: | ||
super().__init__(node, platform) | ||
self._log = self._node.log | ||
|
||
@classmethod | ||
def name(cls) -> str: | ||
return FEATURE_NAME_GPU | ||
|
||
def _install_grid_driver(self, version: str) -> None: | ||
self._log.info("Starting GRID driver installation") | ||
|
||
def _install_cuda_driver(self, version: str = "CUDA_DRIVER") -> None: | ||
self._log.info("Starting CUDA driver installation") | ||
cuda_repo = "" | ||
distro = Linux(self._node) | ||
|
||
# CUDA driver installation for redhat distros | ||
if isinstance(self._node.os, Redhat): | ||
cuda_repo_pkg = f"cuda-repo-rhel7-{version}.x86_64.rpm" | ||
cuda_repo = ( | ||
"http://developer.download.nvidia.com/" | ||
f"compute/cuda/repos/rhel7/x86_64/{cuda_repo_pkg}" | ||
) | ||
distro = Redhat(self._node) | ||
|
||
# CUDA driver installation for Ubuntu distros | ||
elif isinstance(self._node.os, Ubuntu): | ||
os_version = self._node.os.get_os_version() | ||
cuda_repo_pkg = f"cuda-repo-ubuntu{os_version}//./_{version}_amd64.deb" | ||
cuda_repo = ( | ||
"http://developer.download.nvidia.com/compute/" | ||
f"cuda/repos/ubuntu{os_version}//.//x86_64/${cuda_repo_pkg}" | ||
) | ||
distro = Ubuntu(self._node) | ||
|
||
else: | ||
raise LisaException("Distro not supported to install CUDA driver.") | ||
|
||
wget_tool = self._node.tools[Wget] | ||
# download the cuda driver at /tmp/ | ||
wget_tool.get(cuda_repo, "/tmp/", cuda_repo_pkg) | ||
# install the cuda driver rpm | ||
install_result = distro.install_packages(f"/tmp/{cuda_repo_pkg}", signed=False) | ||
if install_result.exit_code != 0: | ||
raise LisaException( | ||
f"Failed to install {cuda_repo_pkg}. stdout: {install_result.stdout}" | ||
) | ||
else: | ||
self._log.info("Sucessfully installed cuda-drivers") | ||
|
||
def install_gpu_dep(self) -> None: | ||
uname_tool = self._node.tools[Uname] | ||
uname_ver = uname_tool.get_linux_information().uname_version | ||
|
||
# install dependency libraries for redhat and CentOS | ||
if isinstance(self._node.os, Redhat): | ||
# install the kernel-devel and kernel-header packages | ||
package_name = f"kernel-devel-{uname_ver} kernel-headers-{uname_ver}" | ||
install_result = self._node.os.install_packages(package_name) | ||
if install_result.exit_code != 0: | ||
raise LisaException( | ||
f"Failed to install {package_name}." | ||
f" stdout: {install_result.stdout}" | ||
) | ||
# mesa-libEGL install/update is require to avoid a conflict between | ||
# libraries - bugzilla.redhat 1584740 | ||
package_name = "mesa-libGL mesa-libEGL libglvnd-devel" | ||
install_result = self._node.os.install_packages(package_name) | ||
if install_result.exit_code != 0: | ||
raise LisaException( | ||
f"Failed to install {package_name}." | ||
f" stdout: {install_result.stdout}" | ||
) | ||
# install dkms | ||
package_name = "dkms" | ||
install_result = self._node.os.install_packages(package_name, signed=False) | ||
if install_result.exit_code != 0: | ||
raise LisaException( | ||
f"Failed to install {package_name}. stdout: {install_result.stdout}" | ||
) | ||
|
||
# install dependency libraraies for Ubuntu | ||
elif isinstance(self._node.os, Ubuntu): | ||
package_name = ( | ||
f"build-essential libelf-dev linux-tools-{uname_ver}" | ||
f" linux-cloud-tools-{uname_ver} python libglvnd-dev ubuntu-desktop" | ||
) | ||
install_result = self._node.os.install_packages(package_name) | ||
if install_result.exit_code != 0: | ||
raise LisaException( | ||
f"Failed to install {package_name}." | ||
f" stdout: {install_result.stdout}" | ||
) | ||
|
||
def install_compute_sdk(self, driver: compute_sdk, version: str) -> None: | ||
if driver == compute_sdk.GRID: | ||
self._install_grid_driver(version) | ||
|
||
elif driver == compute_sdk.CUDA: | ||
self._install_cuda_driver(version) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.