From b21c7e9f34b0572e3588de82d5edf6405f589e41 Mon Sep 17 00:00:00 2001 From: lucasdelimanogueira Date: Fri, 24 May 2024 19:57:49 -0300 Subject: [PATCH 1/5] fix setup.py --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index d94cfc4..0d146ee 100644 --- a/setup.py +++ b/setup.py @@ -22,6 +22,7 @@ apt_nccl = [ ] subprocess.check_call(['sudo', 'apt-get', 'update']) +subprocess.check_call(['sudo', 'apt-get', 'upgrade', '-y', '--allow-change-held-packages']) for package in apt_dependencies: subprocess.check_call(['sudo', 'apt', 'install', package]) From 6d8ff7f9af4d0bd00fa46c42c910988eda1c6fc4 Mon Sep 17 00:00:00 2001 From: lucasdelimanogueira Date: Fri, 24 May 2024 20:06:34 -0300 Subject: [PATCH 2/5] fix distributed allreduce calling python --- norch/distributed/distributed.py | 6 +++--- norch/distributed/run/run.py | 1 + setup.py | 3 ++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/norch/distributed/distributed.py b/norch/distributed/distributed.py index d033ede..b078664 100644 --- a/norch/distributed/distributed.py +++ b/norch/distributed/distributed.py @@ -18,7 +18,7 @@ def broadcast_tensor(tensor): def allreduce_sum_tensor(tensor): - Tensor._C.allreduce_mean_tensor.argtypes = [ctypes.POINTER(CTensor)] - Tensor._C.allreduce_mean_tensor.restype = None + Tensor._C.allreduce_sum_tensor.argtypes = [ctypes.POINTER(CTensor)] + Tensor._C.allreduce_sum_tensor.restype = None - Tensor._C.allreduce_mean_tensor(tensor) + Tensor._C.allreduce_sum_tensor(tensor) diff --git a/norch/distributed/run/run.py b/norch/distributed/run/run.py index f40cb63..2e18211 100644 --- a/norch/distributed/run/run.py +++ b/norch/distributed/run/run.py @@ -22,6 +22,7 @@ def main(): mpiexec_command = [ 'mpiexec', '-n', str(world_size), + '--allow-run-as-root', sys.executable, script_name ] + script_args diff --git a/setup.py b/setup.py index 0d146ee..e8d6c28 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,6 @@ apt_nccl = [ ] subprocess.check_call(['sudo', 'apt-get', 'update']) -subprocess.check_call(['sudo', 'apt-get', 'upgrade', '-y', '--allow-change-held-packages']) for package in apt_dependencies: subprocess.check_call(['sudo', 'apt', 'install', package]) @@ -33,6 +32,8 @@ for package in apt_get_dependencies: subprocess.check_call(['wget', 'https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb']) subprocess.check_call(['sudo', 'dpkg', '-i', 'cuda-keyring_1.0-1_all.deb']) +subprocess.check_call(['sudo', 'apt-mark', 'unhold', 'libnccl-dev', 'libnccl2']) + for package in apt_nccl: subprocess.check_call(['sudo', 'apt', 'install', package]) From 8654374a334064ae42e23726fe76980f47e66fd1 Mon Sep 17 00:00:00 2001 From: lucasdelimanogueira Date: Fri, 24 May 2024 20:13:16 -0300 Subject: [PATCH 3/5] fix setup.py install nccl --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index e8d6c28..083368d 100644 --- a/setup.py +++ b/setup.py @@ -32,6 +32,7 @@ for package in apt_get_dependencies: subprocess.check_call(['wget', 'https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb']) subprocess.check_call(['sudo', 'dpkg', '-i', 'cuda-keyring_1.0-1_all.deb']) +subprocess.check_call(['sudo', 'apt-get', 'upgrade', '-y', '--allow-change-held-packages']) subprocess.check_call(['sudo', 'apt-mark', 'unhold', 'libnccl-dev', 'libnccl2']) for package in apt_nccl: From 3ed877adbf7db873a8adb83d56401ffd3753a2aa Mon Sep 17 00:00:00 2001 From: lucasdelimanogueira Date: Fri, 24 May 2024 20:16:08 -0300 Subject: [PATCH 4/5] fix distributed allreduce calling python --- norch/distributed/distributed.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/norch/distributed/distributed.py b/norch/distributed/distributed.py index b078664..9c797f8 100644 --- a/norch/distributed/distributed.py +++ b/norch/distributed/distributed.py @@ -14,11 +14,11 @@ def broadcast_tensor(tensor): Tensor._C.broadcast_tensor.argtypes = [ctypes.POINTER(CTensor)] Tensor._C.broadcast_tensor.restype = None - Tensor._C.broadcast_tensor(tensor) + Tensor._C.broadcast_tensor(tensor.tensor) def allreduce_sum_tensor(tensor): Tensor._C.allreduce_sum_tensor.argtypes = [ctypes.POINTER(CTensor)] Tensor._C.allreduce_sum_tensor.restype = None - Tensor._C.allreduce_sum_tensor(tensor) + Tensor._C.allreduce_sum_tensor(tensor.tensor) From 01b93132bc944f524879839480764811f9fa6f2d Mon Sep 17 00:00:00 2001 From: lucasdelimanogueira Date: Fri, 24 May 2024 20:31:31 -0300 Subject: [PATCH 5/5] fix setup.py installing --- setup.py | 78 +++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 26 deletions(-) diff --git a/setup.py b/setup.py index 083368d..98a46a2 100644 --- a/setup.py +++ b/setup.py @@ -1,12 +1,11 @@ import setuptools from setuptools.command.install import install import subprocess +import sys -with open("README.md", "r", encoding = "utf-8") as fh: +with open("README.md", "r", encoding="utf-8") as fh: long_description = fh.read() - - apt_dependencies = [ 'nvidia-cuda-toolkit' ] @@ -21,52 +20,79 @@ apt_nccl = [ 'libnccl-dev=2.21.5-1+cuda12.2' ] -subprocess.check_call(['sudo', 'apt-get', 'update']) +def run_command(command): + process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True) + while True: + output = process.stdout.readline() + if output == '' and process.poll() is not None: + break + if output: + print(output.strip()) + sys.stdout.flush() + rc = process.poll() + return rc +print("Updating package lists...") +sys.stdout.flush() +run_command(['sudo', 'apt-get', 'update']) + +print("Installing apt dependencies...") +sys.stdout.flush() for package in apt_dependencies: - subprocess.check_call(['sudo', 'apt', 'install', package]) + run_command(['sudo', 'apt', 'install', '-y', package]) +print("Installing apt-get dependencies...") +sys.stdout.flush() for package in apt_get_dependencies: - subprocess.check_call(['sudo', 'apt-get', 'install', '-y', package]) + run_command(['sudo', 'apt-get', 'install', '-y', package]) -subprocess.check_call(['wget', 'https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb']) -subprocess.check_call(['sudo', 'dpkg', '-i', 'cuda-keyring_1.0-1_all.deb']) +print("Downloading and installing CUDA keyring...") +sys.stdout.flush() +run_command(['wget', 'https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-keyring_1.0-1_all.deb']) +run_command(['sudo', 'dpkg', '-i', 'cuda-keyring_1.0-1_all.deb']) -subprocess.check_call(['sudo', 'apt-get', 'upgrade', '-y', '--allow-change-held-packages']) -subprocess.check_call(['sudo', 'apt-mark', 'unhold', 'libnccl-dev', 'libnccl2']) +print("Upgrading packages...") +sys.stdout.flush() +run_command(['sudo', 'apt-get', 'upgrade', '-y', '--allow-change-held-packages']) +run_command(['sudo', 'apt-mark', 'unhold', 'libnccl-dev', 'libnccl2']) +print("Installing NCCL packages...") +sys.stdout.flush() for package in apt_nccl: - subprocess.check_call(['sudo', 'apt', 'install', package]) + run_command(['sudo', 'apt', 'install', '-y', package]) -subprocess.check_call(['rm', 'cuda-keyring_1.0-1_all.deb']) +print("Cleaning up...") +sys.stdout.flush() +run_command(['rm', 'cuda-keyring_1.0-1_all.deb']) class CustomInstall(install): def run(self): - subprocess.call(['make', '-C', 'build']) + print("Running custom install steps...") + sys.stdout.flush() + run_command(['make', '-C', 'build']) install.run(self) - setuptools.setup( - name = "norch", - version = "0.0.4", - author = "Lucas de Lima", - author_email = "nogueiralucasdelima@gmail.com", - description = "A deep learning framework", - long_description = long_description, - long_description_content_type = "text/markdown", - url = "https://github.com/lucasdelimanogueira/PyNorch", - project_urls = { + name="norch", + version="0.0.4", + author="Lucas de Lima", + author_email="nogueiralucasdelima@gmail.com", + description="A deep learning framework", + long_description=long_description, + long_description_content_type="text/markdown", + url="https://github.com/lucasdelimanogueira/PyNorch", + project_urls={ "Bug Tracker": "https://github.com/lucasdelimanogueira/PyNorch/issues", "Repository": "https://github.com/lucasdelimanogueira/PyNorch" }, - classifiers = [ + classifiers=[ "Programming Language :: Python :: 3", "Operating System :: OS Independent", ], - packages = setuptools.find_packages(), + packages=setuptools.find_packages(), package_data={'norch': ['csrc/*', 'libtensor.so']}, cmdclass={ 'install': CustomInstall, }, - python_requires = ">=3.6" + python_requires=">=3.6" )