Open rowanG077 opened 3 years ago
The entire day I have attempted to package it. I'm stuck on trying to resolve an include for ``. Open3D depends on filament which depends on google test which depends on libcxxabi which apparently depends on libcxx. But that last dependency link goes wrong and I don't know how to fix it.
I have cloned the open3D repo added the nix files and patched some things. It's located here: https://github.com/rowanG077/Open3D/tree/v0.12.0-nix
Any help would be greatly appreciated!
I have isolated the libcxxabi
include issue to the following expression:
clangStdenv.mkDerivation {
name = "filament";
src = fetchFromGitHub {
owner = "intel-isl";
repo = "filament";
rev = "13ad8e25289cb173a4f8e71e85cb4e0d026eacdc";
sha256 = "1pq7cfws4k8havcb589mw8smwgl3hnkw7ignrmw8n0s2wp2zjgnv";
fetchSubmodules = true;
};
buildInputs = [ python ninja xorg.libXi libGLU cmake libcxx libcxxabi ];
};
I marked this as stale due to inactivity. → More info
I hope this will get support in the future. it looks like a pretty exciting new project: http://www.open3d.org/
@rowanG077 this expression works for me. Would you be willing to clean it up so it can be packaged?
(borrows some code from https://github.com/mipmip/nixos/blob/45dea7930eafa18b31424be0e2d850e7a3c7504a/pkgs/open3d/default.nix)
pkgs = nixpkgs.legacyPackages.${system};
pkgsUnfree = import nixpkgs {
inherit system;
config = { allowUnfree = true; };
};
pkgsUnfreeNoCheck = import nixpkgs {
inherit system;
config = { allowUnfree = true; doCheck = false; };
};
python = pkgs.python39;
pythonPackages = python.pkgs;
pytorch-cuda = pkgsUnfreeNoCheck.python39Packages.pytorch.override {
cudaSupport = true;
};
libtorch-cuda = pkgs.libtorch-bin.override { cudaSupport = true; };
open3d = pythonPackages.buildPythonPackage rec {
pname = "open3d";
version = "0.14.1";
format = "wheel";
src = pythonPackages.fetchPypi {
inherit pname version format;
dist = "cp39";
python = "cp39";
abi = "cp39";
platform = "manylinux_2_27_x86_64";
sha256 = "sha256-rgk+O4FDXIIQbCs5zpXR5lV8x7cCekiQfaoD/83JwCA=";
};
patchPhase = ''
${pkgs.unzip}/bin/unzip ./dist/open3d-0.14.1-cp39-cp39-manylinux_2_27_x86_64.whl -d tmp
rm ./dist/open3d-0.14.1-cp39-cp39-manylinux_2_27_x86_64.whl
sed -i 's/sklearn/scikit-learn/g' tmp/open3d-0.14.1.dist-info/METADATA
cd tmp
${pkgs.zip}/bin/zip -0 -r ../dist/open3d-0.14.1-cp39-cp39-manylinux_2_27_x86_64.whl ./*
cd ../
'';
nativeBuildInputs = [
pkgs.autoPatchelfHook
];
buildInputs = with pkgs; [
stdenv.cc.cc.lib
libusb.out
pytorch-cuda
libtensorflow-bin
pkgsUnfree.cudaPackages.cudatoolkit_11.lib
libtorch-cuda
libGL
];
propagatedBuildInputs = with pythonPackages; [
jupyterlab
jupyter-packaging
ipywidgets
tqdm
pyyaml
pandas
plyfile
scipy
scikitlearn
numpy
addict
matplotlib
];
};
@lapp0 Fun fact that linked expression was written by me a while back :), see here: https://gist.github.com/rowanG077/7f46a0807c108fe4b582067f237ae867. Just didn't care to upstream it. The reason for it is because it uses the precompiled wheels. Which I don't really like.
@rowanG077 Are you still working on packaging open3d
? I found that I am in need of packaging it as well. Ideally I think it should be built from source with one c++ library and one python library. But packing the wheel can also work for now.
May I ask what is your current solution to this? I am willing to join the effort if you are still on it. Thanks!
Not stale.
@breakds I'm still interested. But going to "correct" path will take a lot of time I don't have right now. My current solution is that I have packaged the wheel locally.
@rowanG077 Thank you! Do you have an updated wheel solution, or is the 0.12 gist the most up to date?
Meanwhile I'll make an attempt to package it from the source, but since I am less experienced, I might put problems / questioins here.
@breakds yes 0.12 is the most uptodate.
I am trying to get Open3D to work with python3.10 and I have gotten this far.
I seem to have trouble with the libraries that I mention under autoPatchelfIgnoreMissingDeps
If I include mesa
as a dependency most of them are found but at run time I get an error that it can not find the swrast
driver, which seems to me that it is not using the GPU but trying to rely on a fallback solution.
If I leave mesa
out my issue now becomes that libglapi
can not be found. So I have the impression that actually something with libGL
is off, but I'm not sure what.
Which ever way I keep tying things something always does not seem to work properly.
Did anyone manage to get it to work or has any suggestions.
{ config, pkgs, lib, fetchPypi, fetchurl, ... }:
let
unstable = import <nixos-unstable> {
config.allowUnfree = true;
config.cudaSupport = true;
};
my_python = unstable.pkgs.python3.override {
packageOverrides = self: super: {
nbformat = super.buildPythonPackage rec {
pname = "nbformat";
version = "5.7.0";
format = "wheel";
src = pkgs.fetchurl {
url = "https://files.pythonhosted.org/packages/5c/9f/957655d02f43b8bff77e6da08c94472b1229c13e7455bbd662163c9b78c0/nbformat-5.7.0-py3-none-any.whl";
sha256 = "sha256-GwXsLFUsLxrcdF9O3c4erIyp/9Wbuf2FnoJ+qgMTGfk=";
};
buildInputs = with super; [
fastjsonschema
jupyter_core
jsonschema
];
propagatedBuildInputs = with super; [
fastjsonschema
jsonschema
];
};
};
};
ml_python_packages = ps: with ps; [
pip
ipykernel
torch-bin
tensorflowWithoutCuda
gpustat
plotly
scipy
numpy
dash
werkzeug
nbformat
configargparse
ipywidgets
addict
pillow
matplotlib
pandas
pyyaml
scikit-learn
tqdm
pyquaternion
(
buildPythonPackage rec {
pname = "open3d";
version = "0.17.0";
format = "wheel";
src = unstable.python3Packages.fetchPypi {
inherit pname version format;
sha256 = "sha256-PcMAaXMgu2iCRsXQn2gQRYFcMyIlaFc/GWSy11ZDFlc=";
dist = "cp310";
python = "cp310";
abi = "cp310";
platform = "manylinux_2_27_x86_64";
};
nativeBuildInputs = [
unstable.autoPatchelfHook
];
autoPatchelfIgnoreMissingDeps = [
"libLLVM-10.so.1"
#"libglapi.so.0"
#"libdrm.so.2"
#"libexpat.so.1"
#"libXfixes.so.3"
#"libXxf86vm.so.1"
];
buildInputs = with unstable; [
mesa
zstd
stdenv.cc.cc.lib
libusb.out
glibc
libGL
cudaPackages.cudatoolkit
pkgs.libtorch-bin
libtensorflow
];
propagatedBuildInputs = with unstable; [
(my_python.withPackages(
ps: with ps; [
numpy
dash
werkzeug
nbformat
configargparse
ipywidgets
addict
pillow
matplotlib
pandas
pyyaml
scikit-learn
tqdm
pyquaternion
#pywinpty
]))
];
})
];
in
{
nixpkgs.config = {
allowUnfree = true;
cudaSupport = true;
};
# List packages installed in system profile. To search, run:
environment.systemPackages = with unstable.pkgs; [
cudaPackages.cudatoolkit
cudaPackages.cudnn
conda
wget
nvtop
ctop
(my_python.withPackages ml_python_packages)
];
}
libLLVM-10.so.1
can be fixed by symlinking:
postInstall = ''
ln -s "${llvm_10.lib}/lib/libLLVM-10.so" "$out/lib/libLLVM-10.so.1"
''
It's an ubuntu-ism. Adding xorg.libXfixes
, xorg.libXxf86vm
, expat
and libdrm
fixes some more dependencies you marked.
Regarding libglapi
I had the same problem while upgrading.
@rowanG077 Thanks,
yah that brings me down to libglapi.so.0
libdrm.so.2
libexpat.so.1
libXfixes.so.3
and libXxf86vm.so.1
missing.
Those in turn seem to be dependencies of kms_swrast_dri.so
libEGL.so.1
libgallium_dri.so
libGL.so.1
and swrast_dri.so
Could it be that there are some libGL libraries that also simply just need to be remapped?
Is there a way to explore what is inside a package e.g. start a nix-shell and then explore the directories it adds? Then I could try to have a look and see what I find.
@pfmephisto
Yeah, honestly opengl/opencl/nvidia/cuda etc are all a mess in nix. I don't know how it all fits together.
You can use this command to get the nix store path of a package (mesa used here an example):
nix --extra-experimental-features nix-command --extra-experimental-features flakes eval -f '<nixpkgs>' --raw 'mesa'
You can look around in that folder to see what certain package bring into scope.
Hi, did any of you make any progress packaging the latest version?
Tagging @pfmephisto, you are probably interested :).
Yes. I have something working. I have found no way to get pytorch to output the split cuda libraries. I tried various things but building it takes ages so I stopped trying since I didn't really need t anyway. See the pytorchSplitCuda
which is unused.
{ stdenv, lib, buildPythonPackage, fetchPypi, addict
, numpy, matplotlib, ipywidgets, pandas, pyyaml, tqdm
, autoPatchelfHook, llvm_10, xorg, libtorch-bin, libtensorflow, libusb
, cudaPackages, libGL, nbformat, dash, configargparse, pyquaternion, scikit-learn
, expat, pytorchWithCuda }:
let
nbformat-570 = nbformat.overridePythonAttrs (old: rec {
version = "5.7.0";
JUPYTER_PLATFORM_DIRS=1;
src = fetchPypi {
inherit version;
pname = old.pname;
hash = "sha256-HUdgwVwaBCae9crzdb6LmN0vaW5eueYD7Cvwkfmw0/M=";
};
});
pytorchSplitCuda = pytorchWithCuda.overridePythonAttrs (old: rec {
preConfigure = old.preConfigure + ''
export BUILD_SPLIT_CUDA=1
'';
});
in buildPythonPackage rec {
pname = "open3d";
version = "0.17.0";
format = "wheel";
src = fetchPypi {
inherit pname version format;
sha256 = "sha256-PcMAaXMgu2iCRsXQn2gQRYFcMyIlaFc/GWSy11ZDFlc=";
dist = "cp310";
python = "cp310";
abi = "cp310";
platform = "manylinux_2_27_x86_64";
};
nativeBuildInputs = [
autoPatchelfHook
];
autoPatchelfIgnoreMissingDeps = [
"libtorch_cuda_cpp.so"
"libtorch_cuda_cu.so"
];
# Fix llvm library name to match Ubuntu name
# Remove libraries that actually should be provided by environment
postInstall = ''
ln -s "${llvm_10.lib}/lib/libLLVM-10.so" "$out/lib/libLLVM-10.so.1"
rm $out/lib/python3.10/site-packages/open3d/libGL.so.1
rm $out/lib/python3.10/site-packages/open3d/swrast_dri.so
rm $out/lib/python3.10/site-packages/open3d/libgallium_dri.so
rm $out/lib/python3.10/site-packages/open3d/kms_swrast_dri.so
rm $out/lib/python3.10/site-packages/open3d/libEGL.so.1
'';
buildInputs = [
stdenv.cc.cc.lib
libusb.out
libGL
cudaPackages.cudatoolkit
libtorch-bin
libtensorflow
expat
xorg.libXfixes
nbformat
];
propagatedBuildInputs = [
# py deps
numpy
dash
configargparse
scikit-learn
ipywidgets
addict
matplotlib
pandas
pyyaml
tqdm
pyquaternion
pytorchWithCuda
];
}
I ended up switching to Ubuntu (I know 😅), but I need something that worked and did not have more time to debug the derivation.
https://github.com/NixOS/nixpkgs/issues/115218#issuecomment-1578342266
@rowanG077 is this package available in a git repo on your profile?
Could you also help with pointers to convert your code to a flake version?
@OladapoAjala This is what I have based on @rowanG077's original packaging: https://github.com/nixvital/ml-pkgs/blob/main/pkgs/open3d/default.nix
Thanks @breakds , ooks like Open3d is currently unavailable from the ml-pkgs. Can you confirm that the current open3d you have works or it still needs some fine tuning? @breakds
Thanks @breakds , ooks like Open3d is currently unavailable from the ml-pkgs. Can you confirm that the current open3d you have works or it still needs some fine tuning? @breakds
Right, sorry that I left it broken. It should be fixed now in the main branch. However, like @rowanG077 has mentioned there are still some dependencies for patchelf not being found. I tested it just by loading a .pcd
file which works.
Hello I have a similar problem now. On nixos 23.05
flake that @rowanG077 provided worked. But once i updated to nixos 23.11
I get segmentaiton fault on my system. (it worked before update)
Here is my flake.nix
:
Finished processing files...
Segmentation fault (core dumped)
If I update the nixpkgs.url
to 23.11
I get the following error:
error: builder for '/nix/store/crqckibld9wkq7lfmvqz7gykd1aqwxfb-python3.11-nbformat-5.7.0.drv' failed with exit code 2;
last 10 log lines:
> ERROR tests/v4/nbexamples.py - DeprecationWarning: Importing ErrorTree directly from the jsonschema packag...
> ERROR tests/v4/test_convert.py - DeprecationWarning: Importing ErrorTree directly from the jsonschema packag...
> ERROR tests/v4/test_convert.py - DeprecationWarning: Importing ErrorTree directly from the jsonschema packag...
> ERROR tests/v4/test_json.py - DeprecationWarning: Importing ErrorTree directly from the jsonschema packag...
> ERROR tests/v4/test_json.py - DeprecationWarning: Importing ErrorTree directly from the jsonschema packag...
> ERROR tests/v4/test_validate.py - DeprecationWarning: Importing ErrorTree directly from the jsonschema packag...
> ERROR tests/v4/test_validate.py - DeprecationWarning: Importing ErrorTree directly from the jsonschema packag...
> !!!!!!!!!!!!!!!!!!! Interrupted: 20 errors during collection !!!!!!!!!!!!!!!!!!!
> ============================== 20 errors in 3.65s ==============================
> /nix/store/wr08yanv2bjrphhi5aai12hf2qz5kvic-stdenv-linux/setup: line 1559: pop_var_context: head of shell_variables not a function context
For full logs, run 'nix log /nix/store/crqckibld9wkq7lfmvqz7gykd1aqwxfb-python3.11-nbformat-5.7.0.drv'.
I am a nixos newbie and would gladly accept any suggestions how to make it work. Thanks in advance :)
Finally made it work :) :partying_face: :partying_face: on nixos 23.11
and open3d version 0.18
. Here is flake.nix
if anyone is also struggling to make it work :)
{
description = "Opend3d developmen environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-23.11";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils, ... }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
config = { allowUnfree = true; };
};
fetchPypi = pkgs.python311Packages.fetchPypi;
customPython = pkgs.python311.override {
packageOverrides = self: super: {
opencv4 = super.opencv4.override {
enableGtk2 = true;
gtk2 = pkgs.gtk2;
enableFfmpeg = true;
};
};
};
open3d = pkgs.python311Packages.buildPythonPackage rec {
pname = "open3d";
version = "0.18.0";
format = "wheel";
src = pkgs.python311Packages.fetchPypi {
pname = "open3d";
version = "0.18.0";
format = "wheel";
sha256 = "sha256-jj0dGQCo9NlW9oGcJGx4CBclubCIj4VJ0qeknI2qEwM=";
dist = "cp311";
python = "cp311";
abi = "cp311";
platform = "manylinux_2_27_x86_64";
};
nativeBuildInputs = [ pkgs.autoPatchelfHook ];
autoPatchelfIgnoreMissingDeps = [
"libtorch_cuda_cpp.so"
"libtorch_cuda_cu.so"
"libtorch_cuda.so"
"libc10_cuda.so"
];
buildInputs = with pkgs; [
cudaPackages.cudatoolkit
stdenv.cc.cc.lib
libusb.out
libGL
cudaPackages.cudatoolkit
libtorch-bin
libtensorflow
expat
xorg.libXfixes
mesa
xorg.libX11
xorg.libXfixes
];
propagatedBuildInputs = with pkgs.python311Packages; [
nbformat
numpy
dash
configargparse
scikit-learn
ipywidgets
addict
matplotlib
pandas
pyyaml
tqdm
pyquaternion
];
postInstall = ''
ln -s "${pkgs.llvm_10.lib}/lib/libLLVM-10.so" "$out/lib/libLLVM-10.so.1"
rm $out/lib/python3.11/site-packages/open3d/libGL.so.1
rm $out/lib/python3.11/site-packages/open3d/swrast_dri.so
rm $out/lib/python3.11/site-packages/open3d/libgallium_dri.so
rm $out/lib/python3.11/site-packages/open3d/kms_swrast_dri.so
rm $out/lib/python3.11/site-packages/open3d/libEGL.so.1
'';
};
pythonEnv = customPython.withPackages (ps:
with ps; [
matplotlib
numpy
scipy
requests
opencv4
flake8
black
open3d
]);
in {
devShell = pkgs.mkShell {
buildInputs =
[ pythonEnv pkgs.python311Packages.pip pkgs.gtk2 pkgs.ffmpeg ];
shellHook = ''
echo "Welcome to the Python development environment."
'';
};
});
}
This currently doesn't work on unstable due to https://github.com/NixOS/nixpkgs/issues/283954 removing it. Is there a way to get this built on unstable, or will upstream need to be patched for that to be possible?
Project description Open3D is a modern fully featured 3D processing(Pointclouds, meshes etc) environment. I tried to package it myself but quickly ran into my limited nix knowledge. :(
Metadata