Skip to content

main: initialize CUDA before the guest address space so NVIDIA Smooth… - #58

Closed
luizhtss wants to merge 1 commit into
Jetsku:mainfrom
luizhtss:smooth-motion-cuda
Closed

luizhtss wants to merge 1 commit into
Jetsku:mainfrom
luizhtss:smooth-motion-cuda

Conversation

@luizhtss

Copy link
Copy Markdown
Contributor

… Motion can start

NVIDIA Smooth Motion (driver frame generation, RTX 50, now also for Vulkan) makes its frames with CUDA in the driver's present layer, which initializes CUDA when the swapchain is created. By then the guest address space owns every free range below HOST_USER_MAX, so CUDA finds no room for its address range and cuInit fails with CUDA_ERROR_OUT_OF_MEMORY (2). Smooth Motion then stays off for Kyty even when it is enabled in the NVIDIA App; the layer's log (C:/NvPresent/logs/kyty_emulator.exe) shows "CUDA initialization failed. Error code 2".

Main now calls cuInit before any reservation. CUDA's range must not land where the guest maps at fixed addresses (the default map base 0x200000000 and up, the AGC driver memory at 0xfe0000000; initializing CUDA there made that mapping fail), so the free ranges below a floor (512 GiB) are held during cuInit and released right after it. CUDA's range lands above the floor and the guest address space reserves everything around it. The layer's own cuInit then succeeds: "Feature Smooth Motion requested. System support: 1. Device support: 1", and its swapchain is created.

KYTY_CUDA_EARLY_INIT=0 turns it off; KYTY_CUDA_VA_FLOOR_GB moves the floor. Without nvcuda.dll (no NVIDIA driver) nothing happens. Tested with Astro Bot on an RTX 5070 Ti, driver 617.42.

… Motion can start

NVIDIA Smooth Motion (driver frame generation, RTX 50, now also for Vulkan) makes its
frames with CUDA in the driver's present layer, which initializes CUDA when the swapchain
is created. By then the guest address space owns every free range below HOST_USER_MAX,
so CUDA finds no room for its address range and cuInit fails with
CUDA_ERROR_OUT_OF_MEMORY (2). Smooth Motion then stays off for Kyty even when it is
enabled in the NVIDIA App; the layer's log (C:/NvPresent/logs/kyty_emulator.exe) shows
"CUDA initialization failed. Error code 2".

Main now calls cuInit before any reservation. CUDA's range must not land where the guest
maps at fixed addresses (the default map base 0x200000000 and up, the AGC driver memory
at 0xfe0000000; initializing CUDA there made that mapping fail), so the free ranges below
a floor (512 GiB) are held during cuInit and released right after it. CUDA's range lands
above the floor and the guest address space reserves everything around it. The layer's
own cuInit then succeeds: "Feature Smooth Motion requested. System support: 1. Device
support: 1", and its swapchain is created.

KYTY_CUDA_EARLY_INIT=0 turns it off; KYTY_CUDA_VA_FLOOR_GB moves the floor. Without
nvcuda.dll (no NVIDIA driver) nothing happens. Tested with Astro Bot on an RTX 5070 Ti,
driver 617.42.
Jetsku added a commit that referenced this pull request Oct 20, 2026
PR #58 ran cuInit on every NVIDIA run and let CUDA reserve its range
above 512 GiB. The guest user range runs to HOST_USER_MAX
(0xfb_ffff_ffff, about 1008 GiB), so CUDA could land inside it and leave
a permanent hole that a fixed-address guest mapping would hit.

- KYTY_CUDA_EARLY_INIT=1 now turns it on; default off. Only drivers with
  Smooth Motion gain anything, and the rest would pay for an extra DLL,
  CUDA threads and startup time.
- The floor defaults to 1024 GiB (0x100_0000_0000) and
  KYTY_CUDA_VA_FLOOR_GB can only raise it (clamped to 1024..65536).

Co-Authored-By: Jetsku <59046009+Jetsku@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jetsku added a commit that referenced this pull request Oct 20, 2026
…into gtapipe

Co-Authored-By: Jetsku <59046009+Jetsku@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
biggsymobile-png added a commit to biggsymobile-png/KytyPS5 that referenced this pull request Oct 22, 2026
…ged first

At 1008 GiB cuInit still failed with 2 (only 48 MiB of small allocations were
made). 512 GiB is the floor it worked with in PR Jetsku#58.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01MYrbTh2mTBkYrpBvqMpKd7
@Jetsku

Jetsku commented Oct 24, 2026

Copy link
Copy Markdown
Owner

Has been merged and added to a release

@Jetsku Jetsku closed this Oct 24, 2026
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