Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 3.13 with (modified) mimalloc #559

Open
PallHaraldsson opened this issue Sep 19, 2024 · 1 comment
Open

Python 3.13 with (modified) mimalloc #559

PallHaraldsson opened this issue Sep 19, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@PallHaraldsson
Copy link
Contributor

PallHaraldsson commented Sep 19, 2024

A modified version of mimalloc is now included, optional but enabled by default if supported by the platform, and required for the free-threaded build mode.

python/cpython#113141 (comment)

[I.e. likely for all platforms Julia support.] But it's unclear to me if this is a problem for using together since using different malloc.

I've tried before to switch out Julia's use of malloc for mimalloc (it didn't work, I though somebody made it work since).

In C, if you use an alternative malloc you must use its corresponding free, and that rule would translate to Python for its allocations. Julia would do similarily, but assuming still with Libc's standard malloc and free.

I'm just thinking, can you sometimes malloc (indirectly) by Python, then Julia would do the free, and it wouldn't work? Or vice versa?

@PallHaraldsson PallHaraldsson added the enhancement New feature or request label Sep 19, 2024
@PallHaraldsson
Copy link
Contributor Author

PallHaraldsson commented Oct 18, 2024

By messing with the first two files I finally got 3.13 installed, but it gives me an error (likely unrelated to the default mimalloc):

SystemError: Type does not define the tp_name field.
ERROR: InitError: Error initializing 'juliacall.ValueBase'

I'm not sure I edited those two files the right way, last change commented out made it install: # build = "cpython"

julia> @time using PythonCall
    CondaPkg Found dependencies: /home/pharaldsson/.julia/environments/v1.11/CondaPkg.toml
    CondaPkg Found dependencies: /home/pharaldsson/.julia/packages/PythonCall/Nr75f/CondaPkg.toml
...
Transaction

  Prefix: /home/pharaldsson/.julia/environments/v1.11/.CondaPkg/env

  Updating specs:

   - libstdcxx-ng=*
   - numpy=*
   - openssl=*
   - openssl[version='>=3.3.2,<4.0a0']
   - python=*
   - python==3.13

...
Changing numpy-2.1.2-py312h58c1407_0 ==> numpy-2.1.2-py313hb01392b_0

Transaction finished

To activate this environment, use:

    micromamba activate /home/pharaldsson/.julia/environments/v1.11/.CondaPkg/env

Or to execute a single command in this environment, use:

    micromamba run -p /home/pharaldsson/.julia/environments/v1.11/.CondaPkg/env mycommand

SystemError: Type does not define the tp_name field.
ERROR: InitError: Error initializing 'juliacall.ValueBase'
Stacktrace:
  [1] error(s::String)
    @ Base ./error.jl:35
  [2] init_c()
    @ PythonCall.JlWrap.Cjl ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/C.jl:332
  [3] __init__()
    @ PythonCall.JlWrap.Cjl ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/C.jl:337
  [4] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1336
  [5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1324
  [6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any}, ignore_native::Nothing; register::Bool)
    @ Base ./loading.jl:1213
  [7] _include_from_serialized (repeats 2 times)
    @ ./loading.jl:1169 [inlined]
  [8] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool; reasons::Dict{String, Int64}, DEPOT_PATH::Vector{String})
    @ Base ./loading.jl:1985
  [9] _require(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:2450
 [10] __require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:2315
 [11] #invoke_in_world#3
    @ ./essentials.jl:1089 [inlined]
 [12] invoke_in_world
    @ ./essentials.jl:1086 [inlined]
 [13] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:2302
 [14] macro expansion
    @ ./loading.jl:2241 [inlined]
 [15] macro expansion
    @ ./lock.jl:273 [inlined]
 [16] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2198
 [17] #invoke_in_world#3
    @ ./essentials.jl:1089 [inlined]
 [18] invoke_in_world
    @ ./essentials.jl:1086 [inlined]
 [19] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2191
 [20] macro expansion
    @ ./timing.jl:581 [inlined]
 [21] top-level scope
    @ ./REPL[1]:1
during initialization of module Cjl

It is seemingly correctly installed:

shell> /home/pharaldsson/.julia/environments/v1.11/.CondaPkg/env/bin/python
Python 3.13.0 experimental free-threading build | packaged by conda-forge | (main, Oct  8 2024, 20:16:19) [GCC 13.3.0] on linux

Before the above I was figuring things out, and did:

$ micromamba install python=3.13
nodefaults/linux-64                                 ??.?MB @  ??.?MB/s  0.7s
conda-forge/noarch                                  16.9MB @  16.3MB/s  1.2s
nodefaults/noarch                                   ??.?MB @  ??.?MB/s  1.3s
conda-forge/linux-64                                39.0MB @  24.0MB/s  2.1s

error    libmamba Could not lock non-existing path '/home/pharaldsson/.mamba/pkgs'
...

  + libmpdec        4.0.0  h4bc722e_0          conda-forge      90kB
...
  - numpy           2.1.0  py312h1103770_0     conda-forge       8MB
  + numpy           2.1.2  py313h4bf6692_0     conda-forge       8MB
  - openssl         3.3.1  h4bc722e_2          conda-forge       3MB
  + openssl         3.3.2  hb9d3cd8_0          conda-forge       3MB
  - python         3.12.5  h2ad013b_0_cpython  conda-forge      32MB
  + python         3.13.0  h9ebbce0_100_cp313  conda-forge      33MB
  - python_abi       3.12  5_cp312             conda-forge       6kB
  + python_abi       3.13  5_cp313             conda-forge       6kB
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant