google / differential-privacy

Google's differential privacy libraries.
Apache License 2.0
3.08k stars 353 forks source link

Google Colab ? #130

Closed davealexis97 closed 2 years ago

davealexis97 commented 2 years ago

Is there an instruction set to load this into Google Colab? With Colab, I run everything else just fine, but while building the C++ Library, the build fails. I have attached a text file with the exact errors C++LibraryBuildError.txt

Colab Link

FjolleJagt commented 2 years ago

How exactly are you building the library? I'm aware that you can run shell commands and write to disk from colab using the magic commands (e.g. %%shell), but I don't have access to git from there. How did you get the library into the colab? A link to a colab reproducing the error would be ideal.

Looking at the output you linked to, the only errors I can see are things like

./algorithms/partition-selection.h: In member function 'virtual absl::lts_20220623::StatusOr<std::unique_ptr<differential_privacy::PartitionSelectionStrategy> > differential_privacy::GaussianPartitionSelection::Builder::Build()':
./algorithms/partition-selection.h:483:14: error: could not convert 'gaussian' from 'std::unique_ptr<differential_privacy::PartitionSelectionStrategy>' to 'absl::lts_20220623::StatusOr<std::unique_ptr<differential_privacy::PartitionSelectionStrategy> >'
       return gaussian;
              ^~~~~~~~

I don't understand where the lts_20220623 namespace has come from, but it should be possible to convert T to absl::StatusOr<T>. I also don't see the errors you mention in the CI build log: https://github.com/google/differential-privacy/actions/runs/3183960812/jobs/5191807257. Either way, having a working repro would be helpful for digging deeper. Thanks!

davealexis97 commented 2 years ago

How exactly are you building the library? I'm aware that you can run shell commands and write to disk from colab using the magic commands (e.g. %%shell), but I don't have access to git from there. How did you get the library into the colab? A link to a colab reproducing the error would be ideal.

Looking at the output you linked to, the only errors I can see are things like

./algorithms/partition-selection.h: In member function 'virtual absl::lts_20220623::StatusOr<std::unique_ptr<differential_privacy::PartitionSelectionStrategy> > differential_privacy::GaussianPartitionSelection::Builder::Build()':
./algorithms/partition-selection.h:483:14: error: could not convert 'gaussian' from 'std::unique_ptr<differential_privacy::PartitionSelectionStrategy>' to 'absl::lts_20220623::StatusOr<std::unique_ptr<differential_privacy::PartitionSelectionStrategy> >'
       return gaussian;
              ^~~~~~~~

I don't understand where the lts_20220623 namespace has come from, but it should be possible to convert T to absl::StatusOr<T>. I also don't see the errors you mention in the CI build log: https://github.com/google/differential-privacy/actions/runs/3183960812/jobs/5191807257. Either way, having a working repro would be helpful for digging deeper. Thanks!

updated the post with a link to the Google Colab

FjolleJagt commented 2 years ago

Thanks for the colab, that was very helpful! Colab seems to be using an old version of gcc (version 7). Using a more recent version seems to fix the issue:

!curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg
!mv bazel.gpg /etc/apt/trusted.gpg.d/
!echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
!add-apt-repository -y ppa:ubuntu-toolchain-r/test
!apt update
!apt install git bazel-5.3.0 gcc-11 g++-11 bison flex
!git clone https://github.com/google/differential-privacy.git
!cd /content/differential-privacy/cc && CC=gcc-11 bazel-5.3.0 build ...

builds correctly for me in colab.