Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use hasktorch in nixpkgs #10

Merged
merged 1 commit into from
Jan 16, 2025
Merged

Conversation

junjihashimoto
Copy link
Member

@junjihashimoto junjihashimoto commented Jan 6, 2025

This PR improves the workflow by using hasktorch in nixpkgs and installing it with ghc, to avoid long builds of hasktorch.

I uploaded hasktorch to hackage so that we can use hasktorch from nixpkgs.
Building the skeleton is simplified to:

[hasktorch-skeleton (feature/nixpkgs-hasktorch)]$ nix develop
[hasktorch-skeleton (feature/nixpkgs-hasktorch)]$ cabal build all
Configuration is affected by the following files:
- cabal.project
Warning: The package list for 'hackage.haskell.org' is 34 days old.
Run 'cabal update' to get the latest list of available packages.
Resolving dependencies...
Build profile: -w ghc-9.6.6 -O1
In order, the following will be built (use -v for more details):
 - hasktorch-skeleton-0.0.0.0 (lib) (first run)
 - hasktorch-skeleton-0.0.0.0 (exe:example) (first run)
Configuring library for hasktorch-skeleton-0.0.0.0...
Preprocessing library for hasktorch-skeleton-0.0.0.0...
Building library for hasktorch-skeleton-0.0.0.0...
[1 of 1] Compiling HasktorchSkeleton ( src/HasktorchSkeleton.hs, dist-newstyle/build/x86_64-linux/ghc-9.6.6/hasktorch-skeleton-0.0.0.0/build/HasktorchSkeleton.o, dist-newstyle/build/x86_64-linux/ghc-9.6.6/hasktorch-skeleton-0.0.0.0/build/HasktorchSkeleton.dyn_o )
Configuring executable 'example' for hasktorch-skeleton-0.0.0.0...
Preprocessing executable 'example' for hasktorch-skeleton-0.0.0.0...
Building executable 'example' for hasktorch-skeleton-0.0.0.0...
[1 of 1] Compiling Main             ( exe/Main.hs, dist-newstyle/build/x86_64-linux/ghc-9.6.6/hasktorch-skeleton-0.0.0.0/x/example/build/example/example-tmp/Main.o )

exe/Main.hs:3:1: warning: [-Wunused-imports]
    The import of ‘HasktorchSkeleton’ is redundant
      except perhaps to import instances from ‘HasktorchSkeleton’
    To import instances alone, use: import HasktorchSkeleton()
  |
3 | import HasktorchSkeleton
  | ^^^^^^^^^^^^^^^^^^^^^^^^
[2 of 2] Linking dist-newstyle/build/x86_64-linux/ghc-9.6.6/hasktorch-skeleton-0.0.0.0/x/example/build/example/example

flake.nix Outdated
{
devShell = with pkgs; mkShell {
buildInputs = [
libtorch-bin

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@collinarnett Thank you for your review!
This is the same as the one referenced by libtorch-ffi and is not needed.
It is necessary when creating custom operators in C++, but I will remove it from here.

flake.nix Outdated
ghcWithHasktorch
cabal-install
stack
vscode

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think most developers have their own IDE so overriding the path to that IDE here would not be good.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We definitely don't need vscode.
Even if we develop in the environment, it's not necessary when using remote-ssh from vscode on the local macos.

@junjihashimoto junjihashimoto force-pushed the feature/nixpkgs-hasktorch branch 3 times, most recently from f041222 to 18ff067 Compare January 9, 2025 07:54
@junjihashimoto junjihashimoto force-pushed the feature/nixpkgs-hasktorch branch from 18ff067 to 71b2ead Compare January 9, 2025 18:03
@junjihashimoto junjihashimoto merged commit 64187fb into master Jan 16, 2025
4 checks passed
@junjihashimoto junjihashimoto deleted the feature/nixpkgs-hasktorch branch January 16, 2025 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants