setup.py 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/env python3
  2. # Copyright (c) 2017-present, Facebook, Inc.
  3. # All rights reserved.
  4. #
  5. # This source code is licensed under the license found in the LICENSE file in
  6. # the root directory of this source tree. An additional grant of patent rights
  7. # can be found in the PATENTS file in the same directory.
  8. #
  9. #-------------------------------------------------------------------------
  10. #
  11. # Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved.
  12. # Licensed under the Apache License, Version 2.0 (the "License");
  13. # you may not use this file except in compliance with the License.
  14. # You may obtain a copy of the License at
  15. #
  16. # http://www.apache.org/licenses/LICENSE-2.0
  17. #
  18. # Unless required by applicable law or agreed to in writing, software
  19. # distributed under the License is distributed on an "AS IS" BASIS,
  20. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  21. # See the License for the specific language governing permissions and
  22. # limitations under the License.
  23. from setuptools import setup, find_packages, Extension
  24. from torch.utils.cpp_extension import BuildExtension, CUDAExtension, CppExtension
  25. import sys
  26. if sys.version_info < (3,):
  27. sys.exit('Sorry, Python3 is required for fairseq.')
  28. with open('README.md') as f:
  29. readme = f.read()
  30. with open('LICENSE') as f:
  31. license = f.read()
  32. with open('requirements.txt') as f:
  33. reqs = f.read()
  34. extra_compile_args = {'cxx' : ['-O2']}
  35. extra_compile_args['nvcc'] = ['-O3',
  36. '-I./cutlass/',
  37. '-U__CUDA_NO_HALF_OPERATORS__',
  38. '-U__CUDA_NO_HALF_CONVERSIONS__',
  39. '-gencode', 'arch=compute_70,code=sm_70',
  40. '-gencode', 'arch=compute_70,code=compute_70',
  41. '-gencode', 'arch=compute_80,code=sm_80',
  42. '-gencode', 'arch=compute_80,code=compute_80',
  43. ]
  44. strided_batched_gemm = CUDAExtension(
  45. name='strided_batched_gemm',
  46. sources=['fairseq/modules/strided_batched_gemm/strided_batched_gemm.cpp', 'fairseq/modules/strided_batched_gemm/strided_batched_gemm_cuda.cu'],
  47. extra_compile_args=extra_compile_args
  48. )
  49. batch_utils = CppExtension(
  50. name='fairseq.data.batch_C',
  51. sources=['fairseq/data/csrc/make_batches.cpp'],
  52. extra_compile_args={
  53. 'cxx': ['-O2',],
  54. }
  55. )
  56. setup(
  57. name='fairseq',
  58. version='0.5.0',
  59. description='Facebook AI Research Sequence-to-Sequence Toolkit',
  60. long_description=readme,
  61. license=license,
  62. install_requires=reqs.strip().split('\n'),
  63. packages=find_packages(),
  64. ext_modules=[strided_batched_gemm, batch_utils],
  65. cmdclass={
  66. 'build_ext': BuildExtension.with_options(use_ninja=False)
  67. },
  68. test_suite='tests',
  69. )