# generate rtk wheels

**URL:** <https://discourse.itk.org/t/generate-rtk-wheels/6668>\
**Category:** Algorithms\
**Tags:** rtk, python\
**Created:** [June 4, 2024, 12:55am UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668 "2024-06-04T00:55:51Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![zhangm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@zhangm](https://discourse.itk.org/u/zhangm)\
**Post date:** [June 4, 2024, 12:55am UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/1 "2024-06-04T00:55:51Z")

</div>

In order to reduce the loading time if RTK, I first generate itk wheels by [ITKPythonPackage](https://github.com/InsightSoftwareConsortium/ITKPythonPackage/) with `"-DITK_WRAP_IMAGE_DIMS:STRING=2;3"`. And then `pip install itk-rtk-cuda`, but that method will cause the error, so I think I need generate rtk wheels like itk.  
I set `"-DModule_RTK:BOOL=ON",` and `-DRTK_USE_CUDA:BOOL=ON",` on the windows-build-wheels.py like below:

```auto
check_call([
            "cmake",
            "-DCMAKE_MAKE_PROGRAM:FILEPATH=%s" % ninja_executable,
            "-DCMAKE_BUILD_TYPE:STRING=%s" % build_type,
            "-DITK_SOURCE_DIR:PATH=%s" % source_path,
            "-DITK_BINARY_DIR:PATH=%s" % build_path,
            "-DBUILD_TESTING:BOOL=OFF",
            "-DSKBUILD:BOOL=ON",
            "-DPython3_EXECUTABLE:FILEPATH=%s" % python_executable,
            "-DITK_WRAP_unsigned_short:BOOL=ON",
            "-DITK_WRAP_unsigned_char:BOOL=ON",
            "-DITK_WRAP_float:BOOL=ON",
            "-DITK_WRAP_IMAGE_DIMS:STRING=2;3",
            "-DPython3_INCLUDE_DIR:PATH=%s" % python_include_dir,
            "-DPython3_INCLUDE_DIRS:PATH=%s" % python_include_dir,
            "-DPython3_LIBRARY:FILEPATH=%s" % python_library,
            "-DPython3_SABI_LIBRARY:FILEPATH=%s" % python_library,
            "-DWRAP_ITK_INSTALL_COMPONENT_IDENTIFIER:STRING=PythonWheel",
            "-DWRAP_ITK_INSTALL_COMPONENT_PER_MODULE:BOOL=ON",
            "-DPY_SITE_PACKAGES_PATH:PATH=.",
            "-DITK_LEGACY_SILENT:BOOL=ON",
            "-DITK_WRAP_PYTHON:BOOL=ON",
            "-DITK_WRAP_DOC:BOOL=ON",
            "-DDOXYGEN_EXECUTABLE:FILEPATH=C:/P/doxygen/doxygen.exe",
            "-DModule_ITKTBB:BOOL=ON",
            "-DTBB_DIR:PATH=%s" % tbb_dir,
            "-DModule_RTK:BOOL=ON",
            "-DRTK_USE_CUDA:BOOL=ON",
            "-G", "Ninja",
            source_path
        ])

```

But I have been unable to successfully generate it. I want to know if this approach is correct? How should I generate it if it is not correct?

 ![new](https://discourse.itk.org/uploads/default/original/2X/3/3a8bdf0779a46315a285f13b3b9ba2a912efab41.png)

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [June 4, 2024, 12:55pm UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/2 "2024-06-04T12:55:21Z")

</div>

@simon.rit might provide pointers.

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [June 4, 2024, 1:00pm UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/3 "2024-06-04T13:00:14Z")

</div>

I think you need to follow the CI which generates the wheels. You can check the current version

> <https://github.com/RTKConsortium/RTK/blob/master/.github/workflows/build-test-package-python-cuda.yml#L98-L175>

I am working on a migration to pyproject.toml for Python 3.12 compatibility.

---

<div class="post-metadata">

**Author:** ![zhangm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@zhangm](https://discourse.itk.org/u/zhangm)\
**Post date:** [June 5, 2024, 8:36am UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/4 "2024-06-05T08:36:19Z")

</div>

Thak you very much for your reply. I’ll try it. But I have a question: do I need set `"-DITK_WRAP_IMAGE_DIMS:STRING=2;3"`? If I need , where to modify it?

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [June 5, 2024, 8:47am UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/5 "2024-06-05T08:47:42Z")

</div>

I’m not sure, I have never done that. It seems to me that instead of using the distributed ITKPythonBuilds-windows.zip file [here](https://github.com/InsightSoftwareConsortium/ITKPythonPackage/blob/f38e8b0f38580807809b0412235fb2ba0946deba/scripts/windows-download-cache-and-build-module-wheels.ps1#L64), you should simply use your local ITK build.

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [June 5, 2024, 2:21pm UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/6 "2024-06-05T14:21:33Z")

</div>

`ITK_WRAP_IMAGE_DIMS` is a setting in ITK’s CMake configuration, and it needs to be applied in the ITK build which is used.

---

<div class="post-metadata">

**Author:** ![zhangm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@zhangm](https://discourse.itk.org/u/zhangm)\
**Post date:** [June 6, 2024, 6:08am UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/7 "2024-06-06T06:08:26Z")

</div>

Actually I confused now. 😂  
I first generate itk wheels with `"-DITK_WRAP_IMAGE_DIMS:STRING=2;3"` like below:  
 ![企业微信截图_20240606135109](https://discourse.itk.org/uploads/default/original/2X/f/f1bbc32a2cc4d356b463d92d0177a8eb9e8b7998.png)  
And then use pip install itk-rtk-cuda116 from [Pypi](https://pypi.org/project/itk-rtk-cuda116/) to use RTK like `itk.RTK.ThreeDCircularProjectionGeometry.New()`. But there will occur error like this:

 ![企业微信截图_20240606135321](https://discourse.itk.org/uploads/default/original/2X/4/4f1faa22ce2710a6a3da6a2dbe2058236e75fe12.png)  
I think the problem may that the pypi `IMAGE_DIMS:STRING=2;3;4`, which is conflict with itk. So I need to generate a rtk wheels can set same configuration as I generate itk.  
As @simon.rit advise, I generate itkcudacommon wheels by default.  
 ![image](https://discourse.itk.org/uploads/default/original/2X/f/f85fac4bb1349d2c1f72ce83cc1532add1aad23c.png)  
I didn’t find where to set the configuration, I install this whl on my python environment, the error still exists. It seem like there is no difference between the Whl generated by myself and the one I installed from Pypi.

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [June 6, 2024, 6:21am UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/8 "2024-06-06T06:21:10Z")

</div>

As far as my understanding of [ITKPythonPackage](https://github.com/InsightSoftwareConsortium/ITKPythonPackage) goes, it downloads an existing ITK build (from [here](https://github.com/InsightSoftwareConsortium/ITKPythonBuilds)) and compile the module on top of it. You need to do the same but use your ITK build to have the correct set of options.

---

<div class="post-metadata">

**Author:** ![zhangm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@zhangm](https://discourse.itk.org/u/zhangm)\
**Post date:** [June 6, 2024, 6:33am UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/9 "2024-06-06T06:33:55Z")

</div>

Thank you for your prompt reply. Is the website wrong? I only have these things inside when I open it.

 ![企业微信截图_17176554358199](https://discourse.itk.org/uploads/default/original/2X/0/0e3f990ff8fadca2f64b5bb9994cc12750d2e8f1.png)  
As I generate is like below.  
 ![image](https://discourse.itk.org/uploads/default/original/2X/f/f50635a9d2222c39687ce0b3c4b6c7664dc65008.png)

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [June 6, 2024, 6:36am UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/10 "2024-06-06T06:36:37Z")

</div>

No, the builds are distributed as assets of the releases, see e.g. the latest [here](https://github.com/InsightSoftwareConsortium/ITKPythonBuilds/releases/tag/v5.4.0).

---

<div class="post-metadata">

**Author:** ![zhangm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@zhangm](https://discourse.itk.org/u/zhangm)\
**Post date:** [June 17, 2024, 9:33am UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/11 "2024-06-17T09:33:10Z")

</div>

I replace ITKPythonBuild by my generate code. At fist I can successful generate ITKCudaCommon wheels, but late I failed. With the same code, there occur the error like below:

```auto
& "C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\Tools\Launch-VsDevShell.ps1" -Arch amd64 -SkipAutomaticLocation
$env:CC="cl.exe"
$env:CXX="cl.exe"
$env:ITK_PACKAGE_VERSION = 'v5.4.0'
$env:ITKPYTHONPACKAGE_TAG = 'v5.4.0'
$env:ITKPYTHONPACKAGE_ORG = 'InsightSoftwareConsortium'
$env:ITK_MODULE_PREQ = "RTKConsortium/ITKCudaCommon@c7c766a6b944124da21131c6eb689ee75e61bd6e"
$CUDA_VERSION = "116"
$CUDA_VERSION_MAJOR=$CUDA_VERSION.substring(0,2)
$CUDA_VERSION_MINOR=$CUDA_VERSION.substring(2,$CUDA_VERSION.Length-2)
$env:CUDA_PATH = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}"
$env:Path = "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}\bin;" + $env:Path
$LIBCUDART= (Get-Item "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}\bin\cudart64*dll" ).Name
$LIBCUBLAS= (Get-Item "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}\bin\cublas64*dll" ).Name
$LIBCUBLASLT= (Get-Item "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}\bin\cublasLt64*dll" ).Name
$LIBCUFFT= (Get-Item "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}\bin\cufft64*dll" ).Name
./windows-download-cache-and-build-module-wheels.ps1 "9" -setup_options "--lib-paths ""C:/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v${CUDA_VERSION_MAJOR}.${CUDA_VERSION_MINOR}/bin"" --exclude-libs ""nvcuda.dll;concrt140.dll;${LIBCUDART};${LIBCUBLAS};${LIBCUBLASLT};${LIBCUFFT}""" -cmake_options "-DRTK_USE_CUDA:BOOL=ON"

```

 ![企业微信截图_20240617172836](https://discourse.itk.org/uploads/default/original/2X/7/797e9f584b4b952001885d5709bc06e32f6decaa.png)

---

<div class="post-metadata">

**Author:** ![zhangm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@zhangm](https://discourse.itk.org/u/zhangm)\
**Post date:** [June 20, 2024, 3:14am UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/12 "2024-06-20T03:14:29Z")

</div>

Good news, I rebuilt ITK and I can successfully generate ITKCudaCommon wheels. But on the next step, an error occurred during the final step of generating RTK with `cmake-options: '-DRTK_BUILD_APPLICATIONS:BOOL=OFF'`.

 ![企业微信截图_20240620110738](https://discourse.itk.org/uploads/default/original/2X/d/df16642def202a3baaf72b0e5b99f600e1eb9518.png)

Although a wheel was generated, running rtk will result in an error( I use windows and have set `os.add_dll_directory(os.path.join(os.environ['CUDA_PATH'], 'bin'))`).

 ![wheels](https://discourse.itk.org/uploads/default/original/2X/7/713cbba7b109b964c413b170582f3efdd2f2cf0d.png)  
Any help will be appreciate!

---

<div class="post-metadata">

**Author:** ![zhangm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@zhangm](https://discourse.itk.org/u/zhangm)\
**Post date:** [June 21, 2024, 3:25am UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/13 "2024-06-21T03:25:45Z")

</div>

@simon.rit Can you give me some advice? Thank you very much.

---

<div class="post-metadata">

**Author:** ![simon.rit](https://discourse.itk.org/letter_avatar_proxy/v4/letter/s/f08c70/32.png) [@simon.rit](https://discourse.itk.org/u/simon.rit)\
**Post date:** [June 21, 2024, 5:14am UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/14 "2024-06-21T05:14:03Z")

</div>

I wish I could but I don’t see what is the issue. I guess you have to find out which DLL is missing for \_RTKPython.dll. Maybe you can try to find out with [Dependency Walker](https://www.dependencywalker.com/)?

---

<div class="post-metadata">

**Author:** ![zhangm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@zhangm](https://discourse.itk.org/u/zhangm)\
**Post date:** [June 21, 2024, 5:55am UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/15 "2024-06-21T05:55:47Z")

</div>

> [@zhangm](#):
>
> But on the next step, an error occurred during the final step of generating RTK with `cmake-options: '-DRTK_BUILD_APPLICATIONS:BOOL=OFF'`.
> 
> ![企业微信截图_20240620110738](https://discourse.itk.org/uploads/default/original/2X/d/df16642def202a3baaf72b0e5b99f600e1eb9518.png)

There is the probelm. In the final step of generating the wheel, a dependency needs to be added, but an error `RuntimeError: itk\_RTKPython.pyd has a CPU architecture that is not compatible with this wheel` is reported. This resulted in me not having the `itk_rtk.libs` folder when I finally installed the wheels for RTK.  
This dependency can successfully add to ITKCudaCommon wheels.

 ![cudacommon](https://discourse.itk.org/uploads/default/original/2X/7/7744ddbd034b85559b99f8b074b2f3f8ad7a5794.png)

---

<div class="post-metadata">

**Author:** ![zhangm](https://discourse.itk.org/letter_avatar_proxy/v4/letter/z/34f0e0/32.png) [@zhangm](https://discourse.itk.org/u/zhangm)\
**Post date:** [August 2, 2024, 3:12am UTC](https://discourse.itk.org/t/generate-rtk-wheels/6668/16 "2024-08-02T03:12:41Z")

</div>

As RTK2.6 has published, I tried to generate rtk2.6 wheel based on itk5.4(`-DITK_WRAP_IMAGE_DIMS:STRING=2;3`). Unfortunately, it failed too. The ITKCudaComman can generate successfully, but on the last step of rtk build, display some accessories that will generate RTK:

 ![image](https://discourse.itk.org/uploads/default/original/2X/c/c47c030326162b8e8d874439ed72c134d74f2e15.png)  
But I didn’t find the .lib file. And when I opened the \_PTKPython.pyd file by depends, it shows that the `the file was not a 32-bit or 64-bit Windows module.` there was nothing on the file.  
I think that may cause the repair progress failed? Although the wheel generated, but can’t use on the python.  
Have you encountered this situation and given me some advice?
