diff --git a/science/Makefile b/science/Makefile index ae3b09cb79e2..c35f2114c848 100644 --- a/science/Makefile +++ b/science/Makefile @@ -1,531 +1,532 @@ COMMENT = Scientific ports SUBDIR += 2d-rewriter SUBDIR += ALPSCore SUBDIR += ChipmunkPhysics SUBDIR += InsightToolkit SUBDIR += InsightToolkit501 SUBDIR += PETSc SUBDIR += R-cran-DCluster SUBDIR += R-cran-Epi SUBDIR += R-cran-FAdist SUBDIR += R-cran-bayesm SUBDIR += R-cran-cmprsk SUBDIR += R-cran-e1071 SUBDIR += R-cran-eco SUBDIR += R-cran-epicalc SUBDIR += R-cran-etm SUBDIR += R-cran-fastICA SUBDIR += R-cran-kernlab SUBDIR += R-cran-ks SUBDIR += R-cran-snow SUBDIR += R-cran-som SUBDIR += R-cran-udunits2 SUBDIR += abinit SUBDIR += acados SUBDIR += afni SUBDIR += agrum SUBDIR += aircraft-datcom SUBDIR += antioch SUBDIR += apbs SUBDIR += arbor SUBDIR += ascent SUBDIR += atompaw SUBDIR += avogadro2 SUBDIR += avogadrolibs SUBDIR += axom SUBDIR += bagel SUBDIR += bddsolve SUBDIR += berkeleygw SUBDIR += bodr SUBDIR += bout++ SUBDIR += bout++-merging-filaments SUBDIR += buddy SUBDIR += cantera SUBDIR += cardioid SUBDIR += cdf SUBDIR += cdk SUBDIR += cdo SUBDIR += cgnslib SUBDIR += cgribex SUBDIR += checkmol SUBDIR += chemical-mime-data SUBDIR += chemicalfun SUBDIR += chemps2 SUBDIR += chemtool SUBDIR += chemtool-devel SUBDIR += chimes-calculator SUBDIR += chrono SUBDIR += cif-tools SUBDIR += clhep SUBDIR += clipper SUBDIR += code_saturne SUBDIR += colt SUBDIR += conduit SUBDIR += coordgenlibs SUBDIR += cp2k SUBDIR += cp2k-data SUBDIR += csvtk SUBDIR += dakota SUBDIR += dalton SUBDIR += dd_package SUBDIR += devisor SUBDIR += dftbplus SUBDIR += dftd3 SUBDIR += dftd4 SUBDIR += dimod SUBDIR += dirac SUBDIR += dkh SUBDIR += dlib-cpp SUBDIR += drawxtl SUBDIR += dssp SUBDIR += dvc SUBDIR += dwave-preprocessing SUBDIR += dynare SUBDIR += eccodes SUBDIR += elk SUBDIR += elmerfem SUBDIR += epte SUBDIR += erd SUBDIR += ergo SUBDIR += erkale SUBDIR += erkale-pseudopotentials SUBDIR += fastcap SUBDIR += fasthenry SUBDIR += fastjet SUBDIR += feff10 SUBDIR += fleur SUBDIR += frontistr SUBDIR += fsom SUBDIR += fvcom SUBDIR += fvcom-mpi SUBDIR += gabedit SUBDIR += gamess-us SUBDIR += gbtolib SUBDIR += gchemutils SUBDIR += gcp SUBDIR += gdma SUBDIR += geant4 SUBDIR += gemmi SUBDIR += getdp SUBDIR += ghemical SUBDIR += ghmm SUBDIR += gnudatalanguage SUBDIR += gpaw-setups SUBDIR += gramps SUBDIR += gromacs SUBDIR += gsmc SUBDIR += gtamsanalyzer SUBDIR += h5utils SUBDIR += h5z-zfp SUBDIR += harminv SUBDIR += hdf SUBDIR += hdf5 SUBDIR += hdf5-110 SUBDIR += hdf5-18 SUBDIR += healpix SUBDIR += helfem SUBDIR += hepmc3 SUBDIR += highfive SUBDIR += hypre SUBDIR += iboview SUBDIR += isaac-cfd SUBDIR += jdftx SUBDIR += jmol SUBDIR += jstrack SUBDIR += kalzium SUBDIR += kim-api SUBDIR += kplib SUBDIR += kst2 SUBDIR += lammps SUBDIR += lamprop SUBDIR += latte SUBDIR += libaec SUBDIR += libccp4 SUBDIR += libcifpp SUBDIR += libcint SUBDIR += libctl SUBDIR += libecpint SUBDIR += libefp SUBDIR += libgetar SUBDIR += libghemical SUBDIR += libgridxc SUBDIR += libint SUBDIR += libint2 SUBDIR += libint2-psi4 SUBDIR += libkml SUBDIR += liblinear SUBDIR += libmbd SUBDIR += libmsym SUBDIR += libnegf SUBDIR += liboglappth SUBDIR += libpsml SUBDIR += libquantum SUBDIR += libssm SUBDIR += libsvm SUBDIR += libsvm-python SUBDIR += libvdwxc SUBDIR += libxc SUBDIR += liggghts SUBDIR += linearelasticity + SUBDIR += linux-ai-ml-env SUBDIR += linux-zotero SUBDIR += luscus SUBDIR += m-aneos SUBDIR += madness SUBDIR += maeparser SUBDIR += massxpert SUBDIR += mbdyn SUBDIR += mcpl SUBDIR += mcstas SUBDIR += mcstas-comps SUBDIR += mctc-lib SUBDIR += mcxtrace SUBDIR += mcxtrace-comps SUBDIR += mdynamix SUBDIR += medit SUBDIR += meep SUBDIR += metaphysicl SUBDIR += minc2 SUBDIR += mmdb2 SUBDIR += mmg SUBDIR += mmtf-cpp SUBDIR += mol2ps SUBDIR += molgif SUBDIR += molscript SUBDIR += molsketch SUBDIR += mopac SUBDIR += mp2d SUBDIR += mpb SUBDIR += mpqc SUBDIR += mrchem SUBDIR += mrcpp SUBDIR += msms SUBDIR += mstore SUBDIR += multicharge SUBDIR += multiwfn SUBDIR += mutationpp SUBDIR += namd SUBDIR += ncrystal SUBDIR += nest SUBDIR += netcdf SUBDIR += netcdf-cxx SUBDIR += netcdf-fortran SUBDIR += nifticlib SUBDIR += nlcglib SUBDIR += nwchem SUBDIR += nwchem-data SUBDIR += ocean SUBDIR += octopus SUBDIR += openbabel SUBDIR += openems SUBDIR += openkim-models SUBDIR += openmc SUBDIR += openmodelica SUBDIR += openmolcas SUBDIR += openmx SUBDIR += opensim-core SUBDIR += opensph SUBDIR += opsin SUBDIR += optench SUBDIR += orthanc SUBDIR += orthanc-dicomweb SUBDIR += orthanc-mysql SUBDIR += orthanc-postgresql SUBDIR += orthanc-webviewer SUBDIR += p5-Chemistry-3DBuilder SUBDIR += p5-Chemistry-Bond-Find SUBDIR += p5-Chemistry-Canonicalize SUBDIR += p5-Chemistry-Elements SUBDIR += p5-Chemistry-File-MDLMol SUBDIR += p5-Chemistry-File-Mopac SUBDIR += p5-Chemistry-File-PDB SUBDIR += p5-Chemistry-File-SLN SUBDIR += p5-Chemistry-File-SMARTS SUBDIR += p5-Chemistry-File-SMILES SUBDIR += p5-Chemistry-File-VRML SUBDIR += p5-Chemistry-File-XYZ SUBDIR += p5-Chemistry-FormulaPattern SUBDIR += p5-Chemistry-InternalCoords SUBDIR += p5-Chemistry-Isotope SUBDIR += p5-Chemistry-MacroMol SUBDIR += p5-Chemistry-MidasPattern SUBDIR += p5-Chemistry-Mok SUBDIR += p5-Chemistry-Mol SUBDIR += p5-Chemistry-OpenSMILES SUBDIR += p5-Chemistry-Pattern SUBDIR += p5-Chemistry-Reaction SUBDIR += p5-Chemistry-Ring SUBDIR += p5-Geo-BUFR SUBDIR += p5-Geo-Calc SUBDIR += p5-Geo-Coordinates-Converter SUBDIR += p5-Geo-Coordinates-Converter-iArea SUBDIR += p5-Geo-Coordinates-Transform SUBDIR += p5-Geo-WebService-Elevation-USGS SUBDIR += p5-Mcstas-Tools SUBDIR += p5-PerlMol SUBDIR += p5-Physics-Unit SUBDIR += packmol SUBDIR += pagmo2 SUBDIR += paje SUBDIR += paraview SUBDIR += parthenon SUBDIR += pastix SUBDIR += pcmsolver SUBDIR += phonopy SUBDIR += plumed SUBDIR += pnetcdf SUBDIR += polytope SUBDIR += precice SUBDIR += psi4 SUBDIR += pulseview SUBDIR += py-DendroPy SUBDIR += py-GPy SUBDIR += py-GPyOpt SUBDIR += py-HepMC3 SUBDIR += py-HofstadterTools SUBDIR += py-MDAnalysis SUBDIR += py-MDAnalysisTests SUBDIR += py-OpenFermion SUBDIR += py-OpenFermion-Dirac SUBDIR += py-OpenFermion-PySCF SUBDIR += py-OpenMC SUBDIR += py-PubChemPy SUBDIR += py-PyFR SUBDIR += py-PyNE SUBDIR += py-SimpleSpectral SUBDIR += py-abipy SUBDIR += py-access SUBDIR += py-arbor SUBDIR += py-arch SUBDIR += py-asap3 SUBDIR += py-asdf SUBDIR += py-asdf-standard SUBDIR += py-asdf-transform-schemas SUBDIR += py-ase SUBDIR += py-atomium SUBDIR += py-avogadrolibs SUBDIR += py-boutdata SUBDIR += py-boututils SUBDIR += py-cdo SUBDIR += py-cfgrib SUBDIR += py-chainer SUBDIR += py-chainer-chemistry SUBDIR += py-chempy SUBDIR += py-cirq-aqt SUBDIR += py-cirq-core SUBDIR += py-cirq-google SUBDIR += py-cirq-ionq SUBDIR += py-cirq-pasqal SUBDIR += py-cirq-rigetti SUBDIR += py-coards SUBDIR += py-dftbplus SUBDIR += py-dftd4 SUBDIR += py-dimod SUBDIR += py-dipy SUBDIR += py-dlib SUBDIR += py-dwave-cloud-client SUBDIR += py-dwave-greedy SUBDIR += py-dwave-hybrid SUBDIR += py-dwave-inspector SUBDIR += py-dwave-neal SUBDIR += py-dwave-networkx SUBDIR += py-dwave-ocean-sdk SUBDIR += py-dwave-optimization SUBDIR += py-dwave-preprocessing SUBDIR += py-dwave-samplers SUBDIR += py-dwave-system SUBDIR += py-dwave-tabu SUBDIR += py-dwavebinarycsp SUBDIR += py-earthpy SUBDIR += py-eccodes SUBDIR += py-emmet-core SUBDIR += py-esda SUBDIR += py-fresnel SUBDIR += py-gemmi SUBDIR += py-geolinks SUBDIR += py-geomet SUBDIR += py-geometer SUBDIR += py-geometric SUBDIR += py-gpaw SUBDIR += py-gsd SUBDIR += py-h5json SUBDIR += py-h5netcdf SUBDIR += py-h5py SUBDIR += py-h5pyd SUBDIR += py-hiphive SUBDIR += py-hoomd-blue SUBDIR += py-icet SUBDIR += py-inequality SUBDIR += py-ipygany SUBDIR += py-jupyter_jsmol SUBDIR += py-kim-query SUBDIR += py-kimpy SUBDIR += py-kinematics SUBDIR += py-kliff SUBDIR += py-kpLib SUBDIR += py-liac-arff SUBDIR += py-libgetar SUBDIR += py-libpysal SUBDIR += py-lifelines SUBDIR += py-mdp SUBDIR += py-mercantile SUBDIR += py-meshio SUBDIR += py-mmcif SUBDIR += py-mmtf-python SUBDIR += py-molmod SUBDIR += py-moltemplate SUBDIR += py-mp-api SUBDIR += py-mpcontribs-client SUBDIR += py-mplhep SUBDIR += py-mplhep-data SUBDIR += py-mrchem SUBDIR += py-ncrystal SUBDIR += py-netCDF4 SUBDIR += py-netcdf-flattener SUBDIR += py-nglview SUBDIR += py-nibabel SUBDIR += py-obspy SUBDIR += py-oddt SUBDIR += py-openEMS SUBDIR += py-openbabel SUBDIR += py-openpiv SUBDIR += py-optking SUBDIR += py-paida SUBDIR += py-paramz SUBDIR += py-penaltymodel SUBDIR += py-periodictable SUBDIR += py-phono3py SUBDIR += py-phonopy SUBDIR += py-pnetcdf SUBDIR += py-pupynere SUBDIR += py-py3Dmol SUBDIR += py-pyaixi SUBDIR += py-pyberny SUBDIR += py-pycsw SUBDIR += py-pydicom SUBDIR += py-pygeodesy SUBDIR += py-pygeometa SUBDIR += py-pygmo2 SUBDIR += py-pyked SUBDIR += py-pymatgen SUBDIR += py-pymatgen-analysis-alloys SUBDIR += py-pymbd SUBDIR += py-pymol SUBDIR += py-pyosf SUBDIR += py-pyphot SUBDIR += py-pyprecice SUBDIR += py-pyqubo SUBDIR += py-pysal SUBDIR += py-pyscf SUBDIR += py-pyteomics SUBDIR += py-qcelemental SUBDIR += py-qcengine SUBDIR += py-qspin SUBDIR += py-quantities SUBDIR += py-rmf SUBDIR += py-rmsd SUBDIR += py-ruffus SUBDIR += py-sarpy SUBDIR += py-scikit-fuzzy SUBDIR += py-scikit-learn SUBDIR += py-scikit-optimize SUBDIR += py-scikit-sparse SUBDIR += py-scimath SUBDIR += py-scipy SUBDIR += py-scoria SUBDIR += py-sdf SUBDIR += py-seekpath SUBDIR += py-segregation SUBDIR += py-segyio SUBDIR += py-signac SUBDIR += py-sklearn-pandas SUBDIR += py-skrebate SUBDIR += py-spaghetti SUBDIR += py-spglib SUBDIR += py-symfc SUBDIR += py-tensorflow SUBDIR += py-thewalrus SUBDIR += py-tobler SUBDIR += py-trainstation SUBDIR += py-trx-python SUBDIR += py-tweedledum SUBDIR += py-vedo SUBDIR += py-veusz SUBDIR += py-xbout SUBDIR += pybrain SUBDIR += pynn SUBDIR += q SUBDIR += qbox SUBDIR += qcl SUBDIR += qiskit-aer SUBDIR += qmcpack SUBDIR += qt6-quick3dphysics SUBDIR += quantum-espresso SUBDIR += quantum-espresso-pseudopotentials SUBDIR += quantum-jet SUBDIR += qwalk SUBDIR += rdkit SUBDIR += rmf SUBDIR += rubygem-ai4r SUBDIR += rubygem-cdo SUBDIR += rubygem-rgeo SUBDIR += rubygem-rgeo-geojson SUBDIR += rubygem-rgeo-proj4 SUBDIR += rubygem-rgeo-shapefile SUBDIR += rubygem-ruby-netcdf SUBDIR += salome-configuration SUBDIR += salome-kernel SUBDIR += scidavis SUBDIR += sciplot SUBDIR += seacas SUBDIR += segyio SUBDIR += serac SUBDIR += shelxle SUBDIR += siconos SUBDIR += siesta SUBDIR += sigrok-cli SUBDIR += sigrok-firmware SUBDIR += sigrok-firmware-fx2lafw SUBDIR += sigrok-firmware-utils SUBDIR += silo SUBDIR += simbody SUBDIR += simgrid SUBDIR += simint SUBDIR += simlib SUBDIR += simple-dftd3 SUBDIR += simsmith SUBDIR += sirius SUBDIR += smoldyn SUBDIR += sparta SUBDIR += spglib SUBDIR += spheral SUBDIR += step SUBDIR += sz3 SUBDIR += tblite SUBDIR += teem SUBDIR += tfel SUBDIR += tfel-edf SUBDIR += thermofun SUBDIR += tinker SUBDIR += trilinos SUBDIR += ttk SUBDIR += tweedledum SUBDIR += udunits SUBDIR += ukrmol+ SUBDIR += v_sim SUBDIR += vipster SUBDIR += vmd SUBDIR += voro++ SUBDIR += votca SUBDIR += wannier90 SUBDIR += wwplot SUBDIR += wxmacmolplt SUBDIR += xcfun SUBDIR += xcrysden SUBDIR += xdrawchem SUBDIR += xtb SUBDIR += yoda SUBDIR += zotero SUBDIR += zx .include diff --git a/science/linux-ai-ml-env/Makefile b/science/linux-ai-ml-env/Makefile new file mode 100644 index 000000000000..4053a20d88c0 --- /dev/null +++ b/science/linux-ai-ml-env/Makefile @@ -0,0 +1,99 @@ +PORTNAME= ai-ml-env +PORTVERSION= 1.0.0 +CATEGORIES= science linux +MASTER_SITES= https://arrowd.name/ +PKGNAMEPREFIX= linux- +DISTFILES= miniconda3.tar.gz +DIST_SUBDIR= ${PORTNAME} + +MAINTAINER= voxnod@gmail.com +COMMENT= Linux Python environment for running Stable Diffusion models and PyTorch CUDA examples + +ONLY_FOR_ARCHS= amd64 + +LICENSE= MULTI +LICENSE_NAME= Multiple licenses +LICENSE_TEXT= The package contains multiple packages with different licenses +LICENSE_PERMS= dist-mirror pkg-mirror auto-accept + +FETCH_DEPENDS= linux_base-rl9>=9.2:emulators/linux_base-rl9 +BUILD_DEPENDS= linux-rl9-devtools>=0:devel/linux-rl9-devtools +RUN_DEPENDS= linux-nvidia-libs>=0:x11/linux-nvidia-libs \ + linux-rl9-python${PYTHON_SUFFIX}>=0:lang/linux-rl9-python3 \ + nvidia-driver>=0:x11/nvidia-driver + +USES= linux:rl9 +USE_LINUX_PREFIX= yes +USE_GITHUB= nodefault +GH_ACCOUNT= pytorch:examples +GH_PROJECT= examples:examples +GH_TAGNAME= 5dfeb46902baf444010f2f54bcf4dfbea109ae4d:examples + +WRKSRC= ${WRKSRC_examples} + +SUB_FILES= ai-ml-env-bash \ + ai-ml-env-python +SUB_LIST= LOCALBASE=${LOCALBASE} \ + LINUXBASE=${LINUXBASE} + +PLIST_SUB+= PYTHON_SUFFIX=${PYTHON_SUFFIX} \ + PYTHON_VER=${PYTHON_VER} + +CONDA_VERSION= py39_25.1.1-2 +CONDA_SCRIPT= Miniconda3-${CONDA_VERSION}-Linux-x86_64.sh +PYTHON_SUFFIX= 39 +PYTHON_VER= 3.9 +DATA_DIR= ${LOCALBASE}/share/${PORTNAME} + +create-distfile: + ${MKDIR} ${DISTDIR}/${DIST_SUBDIR} + cd ${DISTDIR}/${DIST_SUBDIR} && \ + fetch -a -v https://repo.anaconda.com/miniconda/${CONDA_SCRIPT} + @if [ ! -d "${DISTDIR}/${DIST_SUBDIR}/miniconda3/envs/pytorch" ]; then \ + ${ECHO_MSG} "Miniconda environment 'pytorch' not found. Setting up..."; \ + ${SETENV} HOME=${DISTDIR}/${DIST_SUBDIR} ${SH} ${DISTDIR}/${DIST_SUBDIR}/${CONDA_SCRIPT} -b -s; \ + ${DISTDIR}/${DIST_SUBDIR}/miniconda3/bin/conda create --name pytorch python=${PYTHON_VER} -y; \ + ${LINUXBASE}/bin/bash -c "source ${DISTDIR}/${DIST_SUBDIR}/miniconda3/etc/profile.d/conda.sh && \ + conda activate pytorch && \ + pip install -r ${FILESDIR}/requirements.txt"; \ + fi + cd ${DISTDIR}/${DIST_SUBDIR} && \ + tar -czf miniconda3.tar.gz miniconda3 + ${MAKE} makesum + +do-build: + /compat/linux/bin/cc --sysroot=/compat/linux -m64 -std=c99 -Wall -ldl -fPIC -shared -o ${WRKDIR}/dummy-uvm.so ${FILESDIR}/uvm_ioctl_override.c + +do-install: + @${FIND} ${WRKSRC} -name '*.orig' -delete + # Install Linux Python packages + ${MKDIR} ${STAGEDIR}${PREFIX}/usr/bin + ${FIND} ${WRKDIR}/miniconda3/envs/pytorch/bin -type f -exec ${CP} {} ${STAGEDIR}${PREFIX}/usr/bin \; + ${MKDIR} ${STAGEDIR}${PREFIX}/usr/lib/python${PYTHON_VER} + ${CP} -r ${WRKDIR}/miniconda3/envs/pytorch/lib/python${PYTHON_VER}/site-packages ${STAGEDIR}${PREFIX}/usr/lib/python${PYTHON_VER} + for item in `cat ${FILESDIR}/redundant-items.txt`; do \ + ${RM} -r ${STAGEDIR}${PREFIX}/usr/$$item; \ + done + ${FIND} ${STAGEDIR}${PREFIX}/usr/bin -type f -exec ${REINPLACE_CMD} -i '' 's|^#!.*/miniconda3/envs/pytorch/bin/python|#!/bin/python3|' {} + + # Install Shkhln's lib + ${MKDIR} ${STAGEDIR}${DATADIR} + ${INSTALL_LIB} ${WRKDIR}/dummy-uvm.so ${STAGEDIR}${DATADIR} + # Install Pytorch examples + ${MKDIR} ${STAGEDIR}${DATA_DIR}/pytorch-examples + cd ${WRKSRC} && \ + ${COPYTREE_SHARE} . ${STAGEDIR}${DATA_DIR}/pytorch-examples + ${RM} -r ${STAGEDIR}${DATA_DIR}/pytorch-examples/.github + ${INSTALL_SCRIPT} ${WRKSRC}/run_python_examples.sh ${STAGEDIR}${DATA_DIR}/pytorch-examples + # Install Stable Diffusion sample + ${INSTALL_DATA} ${FILESDIR}/stable-diffusion-sample.py ${STAGEDIR}${DATA_DIR} + # Install demonstration scripts + ${MKDIR} ${STAGEDIR}${LOCALBASE}/bin + ${INSTALL_SCRIPT} ${WRKDIR}/ai-ml-env-bash ${STAGEDIR}${LOCALBASE}/bin/ai-ml-env-bash + ${INSTALL_SCRIPT} ${WRKDIR}/ai-ml-env-python ${STAGEDIR}${LOCALBASE}/bin/ai-ml-env-python + +post-install: + @${FIND} ${STAGEDIR}${PREFIX}/usr/lib/python${PYTHON_VER} -type f | sed -e 's|${STAGEDIR}${PREFIX}/||' >> ${TMPPLIST} + @${FIND} ${STAGEDIR}${DATA_DIR}/pytorch-examples -type f | sed -e 's|${STAGEDIR}||' >> ${TMPPLIST} + @${FIND} ${STAGEDIR}${DATA_DIR} -type d | sed -e 's|${STAGEDIR}|@dir |' >> ${TMPPLIST} + +.include diff --git a/science/linux-ai-ml-env/distinfo b/science/linux-ai-ml-env/distinfo new file mode 100644 index 000000000000..eba6ad95a915 --- /dev/null +++ b/science/linux-ai-ml-env/distinfo @@ -0,0 +1,5 @@ +TIMESTAMP = 1742925172 +SHA256 (ai-ml-env/miniconda3.tar.gz) = 1d9eb42dd753f462f4ccd82ab7716561b90274eeaa45254fd50b879bb09537b7 +SIZE (ai-ml-env/miniconda3.tar.gz) = 3511877484 +SHA256 (ai-ml-env/pytorch-examples-5dfeb46902baf444010f2f54bcf4dfbea109ae4d_GH0.tar.gz) = a024b134dfd1edba649289e551a0cd85bd22424dd76df4303b280e20757a602c +SIZE (ai-ml-env/pytorch-examples-5dfeb46902baf444010f2f54bcf4dfbea109ae4d_GH0.tar.gz) = 7298483 diff --git a/science/linux-ai-ml-env/files/ai-ml-env-bash.in b/science/linux-ai-ml-env/files/ai-ml-env-bash.in new file mode 100644 index 000000000000..cae2b877705b --- /dev/null +++ b/science/linux-ai-ml-env/files/ai-ml-env-bash.in @@ -0,0 +1,6 @@ +#!/bin/sh + +export LD_PRELOAD=%%LINUXBASE%%/usr/share/ai-ml-env/dummy-uvm.so +export SSL_CERT_FILE=%%LINUXBASE%%/usr/lib/python3.9/site-packages/certifi/cacert.pem + +exec %%LINUXBASE%%/usr/bin/bash $* diff --git a/science/linux-ai-ml-env/files/ai-ml-env-python.in b/science/linux-ai-ml-env/files/ai-ml-env-python.in new file mode 100644 index 000000000000..335e571b2259 --- /dev/null +++ b/science/linux-ai-ml-env/files/ai-ml-env-python.in @@ -0,0 +1,4 @@ +#!/bin/sh + +export LD_PRELOAD=%%DATADIR%%/dummy-uvm.so +exec %%LINUXBASE%%/bin/python3 $* diff --git a/science/linux-ai-ml-env/files/patch-reinforcement__learning_actor__critic.py b/science/linux-ai-ml-env/files/patch-reinforcement__learning_actor__critic.py new file mode 100644 index 000000000000..64277c95cea6 --- /dev/null +++ b/science/linux-ai-ml-env/files/patch-reinforcement__learning_actor__critic.py @@ -0,0 +1,13 @@ +--- reinforcement_learning/actor_critic.py.orig 2025-02-09 16:56:58 UTC ++++ reinforcement_learning/actor_critic.py +@@ -10,6 +10,10 @@ from torch.distributions import Categorical + import torch.optim as optim + from torch.distributions import Categorical + ++# numpy.bool8 is deprecated since version 1.24.0 ++if not hasattr(np, 'bool8'): ++ np.bool8 = np.bool_ ++ + # Cart Pole + + parser = argparse.ArgumentParser(description='PyTorch actor-critic example') diff --git a/science/linux-ai-ml-env/files/patch-reinforcement__learning_reinforce.py b/science/linux-ai-ml-env/files/patch-reinforcement__learning_reinforce.py new file mode 100644 index 000000000000..9f1ab1540931 --- /dev/null +++ b/science/linux-ai-ml-env/files/patch-reinforcement__learning_reinforce.py @@ -0,0 +1,12 @@ +--- reinforcement_learning/reinforce.py.orig 2025-02-09 16:56:58 UTC ++++ reinforcement_learning/reinforce.py +@@ -9,6 +9,9 @@ from torch.distributions import Categorical + import torch.optim as optim + from torch.distributions import Categorical + ++# numpy.bool8 is deprecated since version 1.24.0 ++if not hasattr(np, 'bool8'): ++ np.bool8 = np.bool_ + + parser = argparse.ArgumentParser(description='PyTorch REINFORCE example') + parser.add_argument('--gamma', type=float, default=0.99, metavar='G', diff --git a/science/linux-ai-ml-env/files/patch-time__sequence__prediction_train.py b/science/linux-ai-ml-env/files/patch-time__sequence__prediction_train.py new file mode 100644 index 000000000000..66a1b46c198b --- /dev/null +++ b/science/linux-ai-ml-env/files/patch-time__sequence__prediction_train.py @@ -0,0 +1,11 @@ +--- time_sequence_prediction/train.py.orig 2025-02-09 16:56:58 UTC ++++ time_sequence_prediction/train.py +@@ -44,7 +44,7 @@ if __name__ == '__main__': + np.random.seed(0) + torch.manual_seed(0) + # load data and make training set +- data = torch.load('traindata.pt') ++ data = torch.load('traindata.pt', weights_only=False) + input = torch.from_numpy(data[3:, :-1]) + target = torch.from_numpy(data[3:, 1:]) + test_input = torch.from_numpy(data[:3, :-1]) diff --git a/science/linux-ai-ml-env/files/patch-word__language__model_main.py b/science/linux-ai-ml-env/files/patch-word__language__model_main.py new file mode 100644 index 000000000000..549b2f3b8b8b --- /dev/null +++ b/science/linux-ai-ml-env/files/patch-word__language__model_main.py @@ -0,0 +1,11 @@ +--- word_language_model/main.py.orig 2025-03-17 17:25:58 UTC ++++ word_language_model/main.py +@@ -243,7 +243,7 @@ with open(args.save, 'rb') as f: + + # Load the best saved model. + with open(args.save, 'rb') as f: +- model = torch.load(f) ++ model = torch.load(f, weights_only=False) + # after load the rnn params are not a continuous chunk of memory + # this makes them a continuous chunk, and will speed up forward pass + # Currently, only rnn model supports flatten_parameters function. diff --git a/science/linux-ai-ml-env/files/redundant-items.txt b/science/linux-ai-ml-env/files/redundant-items.txt new file mode 100644 index 000000000000..54795ebaf9d0 --- /dev/null +++ b/science/linux-ai-ml-env/files/redundant-items.txt @@ -0,0 +1,41 @@ +bin/2to3-3.9 +bin/c_rehash +bin/clear +bin/idle3.9 +bin/infocmp +bin/lzmadec +bin/lzmainfo +bin/ncursesw6-config +bin/openssl +bin/pip +bin/pip3 +bin/pydoc3.9 +bin/python3.9 +bin/python3.9-config +bin/sqlite3 +bin/sqlite3_analyzer +bin/tabs +bin/tclsh8.6 +bin/tic +bin/toe +bin/tput +bin/tset +bin/wheel +bin/wish8.6 +bin/x86_64-conda-linux-gnu-ld +bin/xz +bin/xzdec +bin/xzdiff +bin/xzgrep +bin/xzless +bin/xzmore +lib/python3.9/site-packages/_distutils_hack/ +lib/python3.9/site-packages/distutils-precedence.pth +lib/python3.9/site-packages/pip-25.0.dist-info/ +lib/python3.9/site-packages/pip/ +lib/python3.9/site-packages/pkg_resources/ +lib/python3.9/site-packages/README.txt +lib/python3.9/site-packages/setuptools-75.8.0-py3.9.egg-info/ +lib/python3.9/site-packages/setuptools/ +lib/python3.9/site-packages/wheel-0.45.1.dist-info/ +lib/python3.9/site-packages/wheel/ diff --git a/science/linux-ai-ml-env/files/requirements.txt b/science/linux-ai-ml-env/files/requirements.txt new file mode 100644 index 000000000000..89aaddb5a303 --- /dev/null +++ b/science/linux-ai-ml-env/files/requirements.txt @@ -0,0 +1,56 @@ +accelerate==1.4.0 +certifi==2025.1.31 +charset-normalizer==3.4.1 +cloudpickle==3.1.1 +contourpy==1.3.0 +cycler==0.12.1 +diffusers==0.32.2 +filelock==3.17.0 +fonttools==4.56.0 +fsspec==2025.3.0 +gym==0.26.2 +gym-notices==0.0.8 +huggingface-hub==0.29.3 +idna==3.10 +importlib_metadata==8.6.1 +importlib_resources==6.5.2 +Jinja2==3.1.6 +kiwisolver==1.4.7 +MarkupSafe==3.0.2 +matplotlib==3.9.4 +mpmath==1.3.0 +networkx==3.2.1 +numpy==2.0.2 +nvidia-cublas-cu12==12.4.5.8 +nvidia-cuda-cupti-cu12==12.4.127 +nvidia-cuda-nvrtc-cu12==12.4.127 +nvidia-cuda-runtime-cu12==12.4.127 +nvidia-cudnn-cu12==9.1.0.70 +nvidia-cufft-cu12==11.2.1.3 +nvidia-curand-cu12==10.3.5.147 +nvidia-cusolver-cu12==11.6.1.9 +nvidia-cusparse-cu12==12.3.1.170 +nvidia-cusparselt-cu12==0.6.2 +nvidia-nccl-cu12==2.21.5 +nvidia-nvjitlink-cu12==12.4.127 +nvidia-nvtx-cu12==12.4.127 +packaging==24.2 +pillow==11.1.0 +psutil==7.0.0 +pyparsing==3.2.1 +python-dateutil==2.9.0.post0 +PyYAML==6.0.2 +regex==2024.11.6 +requests==2.32.3 +safetensors==0.5.3 +six==1.17.0 +sympy==1.13.1 +tokenizers==0.21.0 +torch==2.6.0 +torchvision==0.21.0 +tqdm==4.67.1 +transformers==4.49.0 +triton==3.2.0 +typing_extensions==4.12.2 +urllib3==2.3.0 +zipp==3.21.0 diff --git a/science/linux-ai-ml-env/files/stable-diffusion-sample.py b/science/linux-ai-ml-env/files/stable-diffusion-sample.py new file mode 100644 index 000000000000..fae3f3af4513 --- /dev/null +++ b/science/linux-ai-ml-env/files/stable-diffusion-sample.py @@ -0,0 +1,24 @@ +import sys +import torch +from diffusers import StableDiffusionPipeline + +model_id = "CompVis/stable-diffusion-v1-4" +device = "cuda" if torch.cuda.is_available() else "cpu" +if device == "cpu": + print( + "CUDA is not available\n" + "Please ensure the following:\n" + "1. NVIDIA GPU is present in the system\n" + "2. NVIDIA Driver kernel module is loaded\n" + "3. dummy-uvm library is preloaded" + ) + sys.exit(1) + +pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16) +pipe = pipe.to(device) + +prompt = "a photo of an astronaut riding a horse on mars" +image = pipe(prompt).images[0] + +image.save("astronaut_rides_horse.png") +print(f"Image saved to astronaut_rides_horse.png") diff --git a/science/linux-ai-ml-env/files/uvm_ioctl_override.c b/science/linux-ai-ml-env/files/uvm_ioctl_override.c new file mode 100644 index 000000000000..843c8df762af --- /dev/null +++ b/science/linux-ai-ml-env/files/uvm_ioctl_override.c @@ -0,0 +1,93 @@ +// Downloaded from https://gist.github.com/shkhln/40ef290463e78fb2b0000c60f4ad797e + +#define _GNU_SOURCE + +#include +#include +#include +#include +#include +#include +#include + +// pkg install linux-c7-devtools +// /compat/linux/bin/cc --sysroot=/compat/linux -m64 -std=c99 -Wall -ldl -fPIC -shared -o dummy-uvm.so uvm_ioctl_override.c +// env LD_PRELOAD=$PWD/dummy-uvm.so + +#define NV_UVM_INITIALIZE 0x30000001 +#define NV_UVM_DEINITIALIZE 0x30000002 + +#define NV_ERR_NOT_SUPPORTED 0x56 + +struct NvUvmInitParams +{ + uint64_t flags __attribute__((aligned(8))); + uint32_t status; +}; + +int (*libc_ioctl)(int fd, unsigned long request, ...) = NULL; + +int ioctl(int fd, unsigned long request, ...) { + + if (!libc_ioctl) { + libc_ioctl = dlsym(RTLD_NEXT, "ioctl"); + } + + va_list _args_; + va_start(_args_, request); + void* data = va_arg(_args_, void*); + va_end(_args_); + + if (request == NV_UVM_INITIALIZE) { + struct NvUvmInitParams* params = (struct NvUvmInitParams*)data; + params->status = NV_ERR_NOT_SUPPORTED; + return 0; + } + + if (request == NV_UVM_DEINITIALIZE) { + return 0; + } + + return libc_ioctl(fd, request, data); +} + +int (*libc_open)(const char* path, int flags, ...) = NULL; + +int open(const char* path, int flags, ...) { + + if (!libc_open) { libc_open = dlsym(RTLD_NEXT, "open"); } + + mode_t mode = 0; + + va_list _args_; + va_start(_args_, flags); + + if (flags & O_CREAT) { + mode = va_arg(_args_, int); + } + + va_end(_args_); + + if (strcmp("/dev/nvidia-uvm", path) == 0) { + return libc_open("/dev/null", flags, mode); + } + + return libc_open(path, flags, mode); +} + +FILE* (*libc_fopen)(const char* path, const char* mode) = NULL; + +FILE* fopen(const char* path, const char* mode) { + + if (!libc_fopen) { libc_fopen = dlsym(RTLD_NEXT, "fopen"); } + + if (strncmp(path, "/proc/self/task/", sizeof("/proc/self/task/") - 1) == 0) { + char* tail = strchr(path + sizeof("/proc/self/task/"), '/'); + if (tail != NULL && strcmp(tail, "/comm") == 0) { + assert(strcmp(mode, "wb") == 0); + return libc_fopen("/dev/null", mode); + } + } + + return libc_fopen(path, mode); +} diff --git a/science/linux-ai-ml-env/pkg-descr b/science/linux-ai-ml-env/pkg-descr new file mode 100644 index 000000000000..03dda5eb0c42 --- /dev/null +++ b/science/linux-ai-ml-env/pkg-descr @@ -0,0 +1,5 @@ +This port provides a Linux Python environment tailored for running Stable Diffusion models on NVIDIA GPUs. It includes: + +- A preconfigured Python environment with dependencies for Stable Diffusion and PyTorch examples. +- PyTorch examples. +- Sample scripts for running Stable Diffusion model and PyTorch examples. diff --git a/science/linux-ai-ml-env/pkg-message b/science/linux-ai-ml-env/pkg-message new file mode 100644 index 000000000000..4c744748c5c5 --- /dev/null +++ b/science/linux-ai-ml-env/pkg-message @@ -0,0 +1,32 @@ +[ +{ type: install + message: <