萌新提问 为什么kernel 中的print 不在控制台中显示?

萌新刚接触Taichi,但是跟着教程做的几个例子中,运行后不会在控制台中显示

这里是最简单的例子,后面的例子也不显示。
控制台中就是没有print的内容
这里正常不应该显示 Hello world! 42 么?
我觉得kernel函数貌似已经算了
求大神解答

你好,我测试了一下,应该是可以正常print

2 个赞

似乎是vulkan后端的问题,切到vulkan不输出了

Python 3.10.4 (main, Mar 31 2022, 03:38:35) [Clang 12.0.0 ]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.3.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import taichi as ti
^[[A^[[A^[[A[Taichi] version 1.1.2, llvm 10.0.0, commit f25cf4a2, osx, python 3.10.4

In [2]: ti.init(ti.vulkan)
[mvk-info] MoltenVK version 1.1.10, supporting Vulkan version 1.1.216.
	The following 74 Vulkan extensions are supported:
		VK_KHR_16bit_storage v1
		VK_KHR_8bit_storage v1
		VK_KHR_bind_memory2 v1
		VK_KHR_create_renderpass2 v1
		VK_KHR_dedicated_allocation v3
		VK_KHR_depth_stencil_resolve v1
		VK_KHR_descriptor_update_template v1
		VK_KHR_device_group v4
		VK_KHR_device_group_creation v1
		VK_KHR_driver_properties v1
		VK_KHR_dynamic_rendering v1
		VK_KHR_external_fence v1
		VK_KHR_external_fence_capabilities v1
		VK_KHR_external_memory v1
		VK_KHR_external_memory_capabilities v1
		VK_KHR_external_semaphore v1
		VK_KHR_external_semaphore_capabilities v1
		VK_KHR_fragment_shader_barycentric v1
		VK_KHR_get_memory_requirements2 v1
		VK_KHR_get_physical_device_properties2 v2
		VK_KHR_get_surface_capabilities2 v1
		VK_KHR_imageless_framebuffer v1
		VK_KHR_image_format_list v1
		VK_KHR_maintenance1 v2
		VK_KHR_maintenance2 v1
		VK_KHR_maintenance3 v1
		VK_KHR_multiview v1
		VK_KHR_portability_subset v1
		VK_KHR_push_descriptor v2
		VK_KHR_relaxed_block_layout v1
		VK_KHR_sampler_mirror_clamp_to_edge v3
		VK_KHR_sampler_ycbcr_conversion v14
		VK_KHR_separate_depth_stencil_layouts v1
		VK_KHR_shader_draw_parameters v1
		VK_KHR_shader_float16_int8 v1
		VK_KHR_shader_subgroup_extended_types v1
		VK_KHR_storage_buffer_storage_class v1
		VK_KHR_surface v25
		VK_KHR_swapchain v70
		VK_KHR_swapchain_mutable_format v1
		VK_KHR_timeline_semaphore v2
		VK_KHR_uniform_buffer_standard_layout v1
		VK_KHR_variable_pointers v1
		VK_EXT_debug_marker v4
		VK_EXT_debug_report v10
		VK_EXT_debug_utils v2
		VK_EXT_descriptor_indexing v2
		VK_EXT_fragment_shader_interlock v1
		VK_EXT_hdr_metadata v2
		VK_EXT_host_query_reset v1
		VK_EXT_image_robustness v1
		VK_EXT_inline_uniform_block v1
		VK_EXT_memory_budget v1
		VK_EXT_metal_surface v1
		VK_EXT_private_data v1
		VK_EXT_robustness2 v1
		VK_EXT_sample_locations v1
		VK_EXT_scalar_block_layout v1
		VK_EXT_separate_stencil_usage v1
		VK_EXT_shader_stencil_export v1
		VK_EXT_shader_viewport_index_layer v1
		VK_EXT_subgroup_size_control v2
		VK_EXT_swapchain_colorspace v4
		VK_EXT_texel_buffer_alignment v1
		VK_EXT_vertex_attribute_divisor v3
		VK_AMD_gpu_shader_half_float v2
		VK_AMD_negative_viewport_height v1
		VK_AMD_shader_trinary_minmax v1
		VK_INTEL_shader_integer_functions2 v1
		VK_GOOGLE_display_timing v1
		VK_MVK_macos_surface v3
		VK_MVK_moltenvk v34
		VK_NV_fragment_shader_barycentric v1
		VK_NV_glsl_shader v1
[mvk-info] GPU device:
		model: AMD Radeon Pro 555
		type: Discrete
		vendorID: 0x1002
		deviceID: 0x67ef
		pipelineCacheUUID: 0000277E-0A0F-07D2-0000-000000000000
	supports the following Metal Versions, GPU's and Feature Sets:
		Metal Shading Language 2.2
		GPU Family Mac 2
		GPU Family Mac 1
		GPU Family Common 3
		GPU Family Common 2
		GPU Family Common 1
		macOS GPU Family 2 v1
		macOS GPU Family 1 v4
		macOS GPU Family 1 v3
		macOS GPU Family 1 v2
		macOS GPU Family 1 v1
		macOS Read-Write Texture Tier 2
[mvk-info] GPU device:
		model: Intel(R) HD Graphics 630
		type: Integrated
		vendorID: 0x8086
		deviceID: 0x591b
		pipelineCacheUUID: 0000277E-0A0F-07D2-0000-000000000000
	supports the following Metal Versions, GPU's and Feature Sets:
		Metal Shading Language 2.2
		GPU Family Mac 2
		GPU Family Mac 1
		GPU Family Common 3
		GPU Family Common 2
		GPU Family Common 1
		macOS GPU Family 2 v1
		macOS GPU Family 1 v4
		macOS GPU Family 1 v3
		macOS GPU Family 1 v2
		macOS GPU Family 1 v1
[mvk-info] Created VkInstance for Vulkan version 1.0.0, as requested by app, with the following 0 Vulkan extensions enabled:
[Taichi] Starting on arch=vulkan
[mvk-info] MoltenVK version 1.1.10, supporting Vulkan version 1.1.216.
	The following 74 Vulkan extensions are supported:
		VK_KHR_16bit_storage v1
		VK_KHR_8bit_storage v1
		VK_KHR_bind_memory2 v1
		VK_KHR_create_renderpass2 v1
		VK_KHR_dedicated_allocation v3
		VK_KHR_depth_stencil_resolve v1
		VK_KHR_descriptor_update_template v1
		VK_KHR_device_group v4
		VK_KHR_device_group_creation v1
		VK_KHR_driver_properties v1
		VK_KHR_dynamic_rendering v1
		VK_KHR_external_fence v1
		VK_KHR_external_fence_capabilities v1
		VK_KHR_external_memory v1
		VK_KHR_external_memory_capabilities v1
		VK_KHR_external_semaphore v1
		VK_KHR_external_semaphore_capabilities v1
		VK_KHR_fragment_shader_barycentric v1
		VK_KHR_get_memory_requirements2 v1
		VK_KHR_get_physical_device_properties2 v2
		VK_KHR_get_surface_capabilities2 v1
		VK_KHR_imageless_framebuffer v1
		VK_KHR_image_format_list v1
		VK_KHR_maintenance1 v2
		VK_KHR_maintenance2 v1
		VK_KHR_maintenance3 v1
		VK_KHR_multiview v1
		VK_KHR_portability_subset v1
		VK_KHR_push_descriptor v2
		VK_KHR_relaxed_block_layout v1
		VK_KHR_sampler_mirror_clamp_to_edge v3
		VK_KHR_sampler_ycbcr_conversion v14
		VK_KHR_separate_depth_stencil_layouts v1
		VK_KHR_shader_draw_parameters v1
		VK_KHR_shader_float16_int8 v1
		VK_KHR_shader_subgroup_extended_types v1
		VK_KHR_storage_buffer_storage_class v1
		VK_KHR_surface v25
		VK_KHR_swapchain v70
		VK_KHR_swapchain_mutable_format v1
		VK_KHR_timeline_semaphore v2
		VK_KHR_uniform_buffer_standard_layout v1
		VK_KHR_variable_pointers v1
		VK_EXT_debug_marker v4
		VK_EXT_debug_report v10
		VK_EXT_debug_utils v2
		VK_EXT_descriptor_indexing v2
		VK_EXT_fragment_shader_interlock v1
		VK_EXT_hdr_metadata v2
		VK_EXT_host_query_reset v1
		VK_EXT_image_robustness v1
		VK_EXT_inline_uniform_block v1
		VK_EXT_memory_budget v1
		VK_EXT_metal_surface v1
		VK_EXT_private_data v1
		VK_EXT_robustness2 v1
		VK_EXT_sample_locations v1
		VK_EXT_scalar_block_layout v1
		VK_EXT_separate_stencil_usage v1
		VK_EXT_shader_stencil_export v1
		VK_EXT_shader_viewport_index_layer v1
		VK_EXT_subgroup_size_control v2
		VK_EXT_swapchain_colorspace v4
		VK_EXT_texel_buffer_alignment v1
		VK_EXT_vertex_attribute_divisor v3
		VK_AMD_gpu_shader_half_float v2
		VK_AMD_negative_viewport_height v1
		VK_AMD_shader_trinary_minmax v1
		VK_INTEL_shader_integer_functions2 v1
		VK_GOOGLE_display_timing v1
		VK_MVK_macos_surface v3
		VK_MVK_moltenvk v34
		VK_NV_fragment_shader_barycentric v1
		VK_NV_glsl_shader v1
[mvk-info] GPU device:
		model: AMD Radeon Pro 555
		type: Discrete
		vendorID: 0x1002
		deviceID: 0x67ef
		pipelineCacheUUID: 0000277E-0A0F-07D2-0000-000000000000
	supports the following Metal Versions, GPU's and Feature Sets:
		Metal Shading Language 2.2
		GPU Family Mac 2
		GPU Family Mac 1
		GPU Family Common 3
		GPU Family Common 2
		GPU Family Common 1
		macOS GPU Family 2 v1
		macOS GPU Family 1 v4
		macOS GPU Family 1 v3
		macOS GPU Family 1 v2
		macOS GPU Family 1 v1
		macOS Read-Write Texture Tier 2
[mvk-info] GPU device:
		model: Intel(R) HD Graphics 630
		type: Integrated
		vendorID: 0x8086
		deviceID: 0x591b
		pipelineCacheUUID: 0000277E-0A0F-07D2-0000-000000000000
	supports the following Metal Versions, GPU's and Feature Sets:
		Metal Shading Language 2.2
		GPU Family Mac 2
		GPU Family Mac 1
		GPU Family Common 3
		GPU Family Common 2
		GPU Family Common 1
		macOS GPU Family 2 v1
		macOS GPU Family 1 v4
		macOS GPU Family 1 v3
		macOS GPU Family 1 v2
		macOS GPU Family 1 v1
[mvk-info] Created VkInstance for Vulkan version 1.1.216, as requested by app, with the following 6 Vulkan extensions enabled:
		VK_KHR_external_memory_capabilities v1
		VK_KHR_external_semaphore_capabilities v1
		VK_KHR_get_physical_device_properties2 v2
		VK_KHR_surface v25
		VK_EXT_debug_utils v2
		VK_EXT_metal_surface v1
[I 09/19/22 12:58:18.629 1702216] [vulkan_device_creator.cpp:pick_physical_device@372] Found Vulkan Device 0 (AMD Radeon Pro 555)
[I 09/19/22 12:58:18.629 1702216] [vulkan_device_creator.cpp:pick_physical_device@372] Found Vulkan Device 1 (Intel(R) HD Graphics 630)
[I 09/19/22 12:58:18.629 1702216] [vulkan_device_creator.cpp:create_logical_device@440] Vulkan Device "AMD Radeon Pro 555" supports Vulkan 0 version 1.1.216
[W 09/19/22 12:58:18.629 1702216] [vulkan_device_creator.cpp:create_logical_device@488] Potential non-conformant Vulkan implementation, enabling VK_KHR_portability_subset
[W 09/19/22 12:58:18.629 1702216] [vulkan_device_creator.cpp:create_logical_device@556] Taichi GPU GUI requires wide lines support
[mvk-info] Using MTLEvent for Vulkan semaphores.
[mvk-info] Created VkDevice to run on GPU AMD Radeon Pro 555 with the following 8 Vulkan extensions enabled:
		VK_KHR_bind_memory2 v1
		VK_KHR_dedicated_allocation v3
		VK_KHR_external_memory v1
		VK_KHR_get_memory_requirements2 v1
		VK_KHR_portability_subset v1
		VK_KHR_shader_float16_int8 v1
		VK_KHR_swapchain v70
		VK_KHR_variable_pointers v1

In [3]: @ti.kernel
   ...: def func(a: ti.i32):
   ...:     print("Hello World!", a)
   ...:

In [4]: func(10)
1 个赞

Vulkan 暂时不支持 print 操作,可以先使用其他后端比如(ti.cpu) 来打印。

在下个版本会支持Vulkan后端的print操作,对应的PR在这里:[vulkan] Support printing in debug mode on vulkan backend by ailzhang · Pull Request #6075 · taichi-dev/taichi · GitHub

1 个赞