Skip to content

WIP: Upgrade faiss#4

Closed
h-vetinari wants to merge 6 commits intoconda-forge:masterfrom
h-vetinari:faiss
Closed

WIP: Upgrade faiss#4
h-vetinari wants to merge 6 commits intoconda-forge:masterfrom
h-vetinari:faiss

Conversation

@h-vetinari
Copy link
Member

@conda-forge-linter
Copy link

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

@h-vetinari
Copy link
Member Author

@DavidMChan

tsnecuda is now in conda-forge (irrespective of this PR, which we'll ignore for a moment) - I'd appreciate if you could try the following and let me know if things work as expected:

conda create -n your_test_env -c conda-forge tsnecuda python=3.x

(replacing 3.x with your current favourite python version).

If things are working as intended, then great! 🥳

If not, please let me know more or less urgently, so that we can fix the builds, or - in the worst case - mark them as broken so people cannot install them.

Assuming things are more or less OK, this PR builds tsnecuda against faiss 1.7. It's not merged yet, i.e. cannot normally be installed through conda-forge. But to test it you could download one of the artefacts from this PR (choosing the python/CUDA version you want; if your cuda version is >11.2, take the CUDA=11.2 artefact), and test if the performance drop from CannyLab/tsne-cuda#98 is also replicated with the conda-builds. To do so, unpack the artefact and then do:

conda create -n your_other_env -c "path/to/where/you/unpacked/the/artefact" -c conda-forge tsnecuda python=3.x

Note that faiss & tsnecuda are built against generic blas/lapack interfaces, and you can change the underlying implementation in the environment by adding libblas =*=*mkl (and similarly for openblas/blis).

@DavidMChan
Copy link
Contributor

@h-vetinari
Looks like I have some issues with the conda-forge build using the command:

conda create -n tsne_test -c conda-forge tsnecuda python=3.8

Not sure if this is user error, or if it's another problem....

Error is:

Collecting package metadata (current_repodata.json): failed

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/exceptions.py", line 1079, in __call__
        return func(*args, **kwargs)
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/cli/main.py", line 84, in _main
        exit_code = do_call(args, p)
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/cli/conda_argparse.py", line 83, in do_call
        return getattr(module, func_name)(args, parser)
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/cli/main_create.py", line 41, in execute
        install(args, parser, 'create')
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/cli/install.py", line 261, in install
        unlink_link_transaction = solver.solve_for_transaction(
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/core/solve.py", line 114, in solve_for_transaction
        unlink_precs, link_precs = self.solve_for_diff(update_modifier, deps_modifier,
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/core/solve.py", line 157, in solve_for_diff
        final_precs = self.solve_final_state(update_modifier, deps_modifier, prune, ignore_pinned,
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/core/solve.py", line 262, in solve_final_state
        ssc = self._collect_all_metadata(ssc)
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/common/io.py", line 88, in decorated
        return f(*args, **kwds)
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/core/solve.py", line 425, in _collect_all_metadata
        index, r = self._prepare(prepared_specs)
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/core/solve.py", line 1020, in _prepare
        reduced_index = get_reduced_index(self.prefix, self.channels,
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/core/index.py", line 291, in get_reduced_index
        push_record(record)
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/core/index.py", line 265, in push_record
        combined_depends = record.combined_depends
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/models/records.py", line 332, in combined_depends
        result = {ms.name: ms for ms in MatchSpec.merge(self.depends)}
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/models/match_spec.py", line 480, in merge
        reduce(lambda x, y: x._merge(y, union), group) if len(group) > 1 else group[0]
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/models/match_spec.py", line 480, in <lambda>
        reduce(lambda x, y: x._merge(y, union), group) if len(group) > 1 else group[0]
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/models/match_spec.py", line 511, in _merge
        final = this_component.merge(that_component)
      File "/home/davidchan/Apps/miniconda3/lib/python3.8/site-packages/conda/models/match_spec.py", line 763, in merge
        raise ValueError("Incompatible component merge:\n  - %r\n  - %r"
    ValueError: Incompatible component merge:
      - '*cuda'
      - '*_cuda'

`$ /home/davidchan/Apps/miniconda3/bin/conda create -n tsne_test -c conda-forge tsnecuda python=3.8`

  environment variables:
                 CIO_TEST=<not set>
          CONDA_CHANGEPS1=false
        CONDA_DEFAULT_ENV=base
                CONDA_EXE=/home/davidchan/Apps/miniconda3/bin/conda
             CONDA_PREFIX=/home/davidchan/Apps/miniconda3
    CONDA_PROMPT_MODIFIER=(base)
         CONDA_PYTHON_EXE=/home/davidchan/Apps/miniconda3/bin/python
               CONDA_ROOT=/home/davidchan/Apps/miniconda3
              CONDA_SHLVL=1
                    CPATH=/opt/intel/compilers_and_libraries_2018.3.222/linux/mkl/include
           CURL_CA_BUNDLE=<not set>
          LD_LIBRARY_PATH=/opt/intel/compilers_and_libraries_2018.3.222/linux/tbb/lib/intel64_li
                          n/gcc4.7:/opt/intel/compilers_and_libraries_2018.3.222/linux/compiler/
                          lib/intel64_lin:/opt/intel/compilers_and_libraries_2018.3.222/linux/mk
                          l/lib/intel64_lin:/usr/local/cuda/lib64
             LIBRARY_PATH=/opt/intel/compilers_and_libraries_2018.3.222/linux/tbb/lib/intel64_li
                          n/gcc4.7:/opt/intel/compilers_and_libraries_2018.3.222/linux/compiler/
                          lib/intel64_lin:/opt/intel/compilers_and_libraries_2018.3.222/linux/mk
                          l/lib/intel64_lin
                  NLSPATH=/opt/intel/compilers_and_libraries_2018.3.222/linux/mkl/lib/intel64_li
                          n/locale/%l_%t/%N
                     PATH=/home/davidchan/Apps/miniconda3/bin:/home/davidchan/.local/bin:/home/d
                          avidchan/.cargo/bin:/home/davidchan/.krew/bin:/home/davidchan/.nvm/ver
                          sions/node/v14.17.1/bin:/home/davidchan/Apps/miniconda3/bin:/home/davi
                          dchan/Apps/miniconda3/condabin:/usr/local/sbin:/usr/local/bin:/usr/sbi
                          n:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local
                          /cuda/bin:/home/davidchan/.local/bin
          PKG_CONFIG_PATH=/opt/intel/compilers_and_libraries_2018.3.222/linux/mkl/bin/pkgconfig
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>

     active environment : base
    active env location : /home/davidchan/Apps/miniconda3
            shell level : 1
       user config file : /home/davidchan/.condarc
 populated config files :
          conda version : 4.10.3
    conda-build version : 3.21.4
         python version : 3.8.8.final.0
       virtual packages : __cuda=11.2=0
                          __linux=5.11.0=0
                          __glibc=2.31=0
                          __unix=0=0
                          __archspec=1=x86_64
       base environment : /home/davidchan/Apps/miniconda3  (writable)
      conda av data dir : /home/davidchan/Apps/miniconda3/etc/conda
  conda av metadata url : None
           channel URLs : https://conda.anaconda.org/conda-forge/linux-64
                          https://conda.anaconda.org/conda-forge/noarch
                          https://repo.anaconda.com/pkgs/main/linux-64
                          https://repo.anaconda.com/pkgs/main/noarch
                          https://repo.anaconda.com/pkgs/r/linux-64
                          https://repo.anaconda.com/pkgs/r/noarch
          package cache : /home/davidchan/Apps/miniconda3/pkgs
                          /home/davidchan/.conda/pkgs
       envs directories : /home/davidchan/Apps/miniconda3/envs
                          /home/davidchan/.conda/envs
               platform : linux-64
             user-agent : conda/4.10.3 requests/2.25.1 CPython/3.8.8 Linux/5.11.0-40-generic ubuntu/20.04.3 glibc/2.31

@h-vetinari
Copy link
Member Author

I've never seen such an error upon environment creation (resp. package metadata collection already):

    ValueError: Incompatible component merge:
      - '*cuda'
      - '*_cuda'

It's particularly unusual because the installation of the package gets tested successfully in CI. I guess the only pertinent difference is the presence/absence of the __cuda virtual package?

Any ideas @conda-forge/conda?

@h-vetinari
Copy link
Member Author

@isuruf
Thanks a lot for taking a look! The divergence from the run-exports from faiss seems like the obvious answer. 🤦

It's unrelated to this PR though, so I'll fix it in another one.

@h-vetinari
Copy link
Member Author

h-vetinari commented Dec 3, 2021

So @DavidMChan, that was an unusual error that had happened, but it should be fixed now... 😅

Would you mind giving this another shot? I.e. testing the current packages, as well as the build against faiss 1.7 from this PR?

PS. the "how-to" from the comment above is still correct, but the link for the artefacts has changed.

@DavidMChan
Copy link
Contributor

Looks like the 1.6.5 version is working now! Great work on this, I really appreciate the help (I've been trying to get this building correctly for conda for a really long time, and I've never had any success). I'll push an update to the readme for recommended installation procedures.

In terms of updating to 1.7.x, it works! and it does seem like this may have fixed the issues in CannyLab/tsne-cuda#98 - though I did notice that the version string in tsnecuda is incorrect (We generate it dynamically, but it might make sense to push a fix to the upstream tsnecuda for this, we could just hardcode the version string instead of trying to generate it dynamically).

It's also pretty easy to push an upstream update which removes setuptools as a runtime dependency (we only use it for locating the relative path of the libtsnecuda.so file), so we could hack around that using __file__. Are there any other updates that I should consider for 3.0.2?

@h-vetinari
Copy link
Member Author

Happy to hear it! :)

Regarding the version string - I had to patch that because it was running into compilation issues, and while doing so, I noticed that the patch-level of the version wasn't being baked in correctly (presumably it was implicitly inserting a float, which cannot have two dots).

I had asked you at the time if you could review the patches, but maybe that was too easily overlooked.

You can see the patches within the repo, but I've now also pushed the branch upon which these patches are based. As I said in that comment, all these patches could use improvement, but it would be great if they could be included in the upstream repo eventually and therefore avoid the need to carry patches on the feedstock at all (for the third one, I'll probably switch to creating a build/ folder in the recipe).

@h-vetinari
Copy link
Member Author

Ah, and once we move to faiss 1.7, it would also be possible in principle to support windows. There might be some patches generated due to that (once I find the time, depending on how gnarly it is) which I'd happily upstream.

@h-vetinari
Copy link
Member Author

PS: "Yes please!" to getting rid of setuptools as a run-dependency. 🙃

@h-vetinari
Copy link
Member Author

Ping @DavidMChan, any comments/questions about the above (e.g. the patches re:changes for 3.0.2)?

@DavidMChan
Copy link
Contributor

Ah - sorry about this! It's been finals week! I think that I merged what is required (as well as removed setuptools) in the following branch: https://github.com/CannyLab/tsne-cuda/tree/3.0.1-rc0

Let me know if that looks good, and I'll start the process to deploy this more broadly.

@h-vetinari
Copy link
Member Author

h-vetinari commented Dec 10, 2021

Ah - sorry about this! It's been finals week!

Please don't worry about this then - I was just curious what the current status is.

@h-vetinari
Copy link
Member Author

Gentle ping @DavidMChan, hope you got through the finals well. :)

@DavidMChan
Copy link
Contributor

DavidMChan commented Dec 21, 2021

Hi @h-vetinari! Thanks! I pushed the upstream changes to the 3.0.1-RC0 branch - and I've been waiting for you to confirm that's all that you need before releasing.... I also think I replied to the other two patches - is there something else you need me to take a look at?

@h-vetinari
Copy link
Member Author

Hey David, sorry, this got lost with the holidays on my end. This is green, so from my side there's nothing more that's necessary.

@h-vetinari
Copy link
Member Author

so from my side there's nothing more that's necessary.

Perhaps with the tiny exception of actually releasing 3.0.1-RC0 as 3.0.1. ;-)

@DavidMChan
Copy link
Contributor

Ok! Sorry about this, since it got lost for a sec, but you should be all good to go now!

@h-vetinari
Copy link
Member Author

Awesome, thanks! Upgrade PR (#6) is merged, builds should be available in 2-3 hours. :)

@h-vetinari h-vetinari closed this Feb 8, 2022
@h-vetinari h-vetinari deleted the faiss branch February 8, 2022 06:55
@h-vetinari
Copy link
Member Author

Next stop: windows builds. :)

@hanjing202302-ship-it
Copy link

Hello, thank you very much for your hard work!
Is there any progress with the Windows version of tsnecuda? Currently, I haven't found any available Python packages specifically for Windows. I am eagerly awaiting your reply.

@h-vetinari
Copy link
Member Author

There was some work on this in #7, but it stalled for reasons I cannot remember. More importantly, faiss is currently not maintained, and that feedstock needs a quite substantial overhaul. I'm not using faiss myself, so this would have to come from someone else (though I'm willing to help review PRs).

@hanjing202302-ship-it
Copy link

#7中曾有过一些相关工作,但由于一些我记不清楚的原因而盗版不前。更重要的是,faiss目前已停止维护,而且其源文件需要进行相当大的跟踪。我自己不使用工作faiss,所以这需要其他人来完成(不过我很乐意帮忙审核公关)。
Thanks for your reply. You mentioned here that you used faiss 1.17.1 (the first version with Windows support). Is it faiss-gpu or faiss-cpu? Thanks.

@h-vetinari
Copy link
Member Author

Thanks for your reply. You mentioned here that you used faiss 1.17.1 (the first version with Windows support). Is it faiss-gpu or faiss-cpu? Thanks.

I said 1.7.1, not 1.17. In conda-forge, faiss is the real package that comes in both variants; faiss-gpu and faiss-cpu are just for convenience (and depend on a specific variant of faiss). You can check the faiss recipe

@DavidMChan
Copy link
Contributor

You can also consider this: CannyLab/tsne-cuda#130 - which should allow you to build windows support from scratch (or at least is a preview version of what could work).

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.

4 participants