PyNorch/setup.py

101 lines
2.9 KiB
Python
Raw Normal View History

2024-05-10 20:12:15 -03:00
import setuptools
2024-05-11 01:45:59 -03:00
from setuptools.command.install import install
import subprocess
2024-05-24 20:31:31 -03:00
import sys
2024-05-10 20:12:15 -03:00
2024-05-24 20:31:31 -03:00
with open("README.md", "r", encoding="utf-8") as fh:
2024-05-10 20:12:15 -03:00
long_description = fh.read()
2024-05-11 01:45:59 -03:00
apt_dependencies = [
'nvidia-cuda-toolkit'
]
2024-05-24 15:12:53 -03:00
apt_get_dependencies = [
'mpi',
2024-05-28 10:28:54 -03:00
'libopenmpi-dev',
'openmpi-common',
'openmpi-bin'
2024-05-24 15:12:53 -03:00
]
2024-05-24 18:19:39 -03:00
apt_nccl = [
'libnccl2=2.21.5-1+cuda12.2',
2024-05-24 19:48:37 -03:00
'libnccl-dev=2.21.5-1+cuda12.2'
2024-05-24 18:19:39 -03:00
]
2024-05-24 20:31:31 -03:00
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()
2024-05-11 01:45:59 -03:00
for package in apt_dependencies:
2024-05-24 20:31:31 -03:00
run_command(['sudo', 'apt', 'install', '-y', package])
2024-05-11 01:45:59 -03:00
2024-05-24 20:31:31 -03:00
print("Installing apt-get dependencies...")
sys.stdout.flush()
2024-05-24 15:12:53 -03:00
for package in apt_get_dependencies:
2024-05-24 20:31:31 -03:00
run_command(['sudo', 'apt-get', 'install', '-y', package])
2024-05-24 15:12:53 -03:00
2024-05-24 20:31:31 -03:00
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'])
2024-05-24 18:19:39 -03:00
2024-05-24 20:31:31 -03:00
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'])
2024-05-24 20:31:31 -03:00
print("Installing NCCL packages...")
sys.stdout.flush()
2024-05-24 18:19:39 -03:00
for package in apt_nccl:
2024-05-24 20:31:31 -03:00
run_command(['sudo', 'apt', 'install', '-y', package])
2024-05-24 18:19:39 -03:00
2024-05-24 20:31:31 -03:00
print("Cleaning up...")
sys.stdout.flush()
run_command(['rm', 'cuda-keyring_1.0-1_all.deb'])
2024-05-24 19:48:37 -03:00
2024-05-11 01:45:59 -03:00
class CustomInstall(install):
def run(self):
2024-05-24 20:31:31 -03:00
print("Running custom install steps...")
sys.stdout.flush()
run_command(['make', '-C', 'build'])
2024-05-11 01:45:59 -03:00
install.run(self)
2024-05-10 20:12:15 -03:00
setuptools.setup(
2024-05-24 20:31:31 -03:00
name="norch",
2024-06-05 21:07:07 -03:00
version="0.0.7",
2024-05-24 20:31:31 -03:00
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={
2024-05-10 20:12:15 -03:00
"Bug Tracker": "https://github.com/lucasdelimanogueira/PyNorch/issues",
"Repository": "https://github.com/lucasdelimanogueira/PyNorch"
},
2024-05-24 20:31:31 -03:00
classifiers=[
2024-05-10 20:12:15 -03:00
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
],
2024-05-24 20:31:31 -03:00
packages=setuptools.find_packages(),
2024-05-11 01:45:59 -03:00
package_data={'norch': ['csrc/*', 'libtensor.so']},
cmdclass={
'install': CustomInstall,
},
2024-05-24 20:31:31 -03:00
python_requires=">=3.6"
2024-05-10 20:12:15 -03:00
)