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

Juliacall with SB3 for RL in WSL bings to segmetation fault problems #577

Open
Toquika opened this issue Nov 23, 2024 · 0 comments
Open
Labels
question Further information is requested

Comments

@Toquika
Copy link

Toquika commented Nov 23, 2024

I am trying to train a RL agent using SB3, torch, and Gymnasium. I use a linux environment through wsl2 (Ubuntu-22.04), and VisualStudio Code. To speed up the step phase in my environment, I invoke Julia passing through juliacall to propagate the dynamics of my problem. I report here the main points of my implementation.

Problem dynamics in Julia: bcr4bp.jl

# Import dependencies
using OrdinaryDiffEq

# Struct for environment dynamical settings
struct bcr4bpEnvJl

  # Reference quantities
  mu::Float64
  mu3::Float64
  om3::Float64
  rho3::Float64
  tau0::Float64
  alpha0::Float64

  # Propagator
  absTol::Float64
  relTol::Float64

end

# Dynamical function for ODE propagation
function bcr4bpRHS(dxx, xx, ENV::bcr4bpEnvJl, tau)

  # Parameters extraction
  mu = ENV.mu
  mu3 = ENV.mu3
  om3 = ENV.om3
  rho3 = ENV.rho3
  tau0 = ENV.tau0
  alpha0 = ENV.alpha0

  # Retrieve states
  x = xx[1]
  y = xx[2]
  z = xx[3]

  xd = xx[4]
  yd = xx[5]
  zd = xx[6]

  alpha = om3 * (tau - tau0) + alpha0

  # Compute distances from primaries
  r1 = sqrt((x+mu)^2 + y^2 + z^2);  
  r2 = sqrt((x+mu-1)^2 + y^2 + z^2);  
  r3 = sqrt((x-rho3*cos(alpha))^2 + (y-rho3*sin(alpha))^2 + z^2);

  # Compute RHS
  ff3 = [xd;
         yd;
         zd;
         2*yd + x - (1-mu)*(x+mu)/r1^3 - mu*(x+mu-1)/r2^3;
         -2*xd + y - (1-mu)*y/r1^3 - mu*y/r2^3;
         -(1-mu)*z/r1^3 - mu*z/r2^3;;]

  ff4 = [0;
         0;
         0;
         -mu3*(x-rho3*cos(alpha))/r3^3 - mu3/rho3^2*cos(alpha);
         -mu3*(y-rho3*sin(alpha))/r3^3 - mu3/rho3^2*sin(alpha);
         -mu3*z/r3^3;;]

  # Return
  dyn = ff3 .+ ff4
  dxx[1:6] = dyn[:]

end

# Propagation
function bcr4bpPropagation(xx0, tSpan, ENV::bcr4bpEnvJl, is_flow)

  # Formulate ODE problem
  prob = ODEProblem(bcr4bpRHS, xx0, tSpan, ENV)

  # Perform propagation
  sol = solve(prob, Vern9(), abstol=ENV.absTol, reltol=ENV.relTol)

  # Check solution and return
  if sol.retcode == ReturnCode.Success

    if is_flow
      return sol[:, end]
    else
      return sol
    end

  else

    return 0
    
  end

end

RL Gymnasium environment mission_env.py

import gymnasium as gym
import numpy as np
from copy import deepcopy
from gymnasium import spaces
from src.astro.bcr4bp.bcr4bp import Bcr4bp
from src.utils.mission_settings import MissionSettings
from src.utils.propagator import Propagator
from src.utils import util_methods

import juliacall
from juliacall import Main as jl_main
jl_main.include("src/astro/bcr4bp/bcr4bp.jl")

class FbpMissionEnv(gym.Env):

    metadata = {"render_modes": ["rgb_array"]}

    def __init__(self,
                 dt_step: np.float64,
                 bcr4bp: Bcr4bp,
                 mission_settings: MissionSettings,
                 propagator: Propagator):
    
        # Init code ...
        # Julia environment definition
        self._bcr4bp_env_jl = jl_main.bcr4bpEnvJl(jl_main.Float64(self._bcr4bp.mu),
                              jl_main.Float64(self._bcr4bp.mu_tertiary),
                              jl_main.Float64(self._bcr4bp.om_tertiary),
                              jl_main.Float64(self._bcr4bp.dist_tertiary),
                              jl_main.Float64(self._bcr4bp.tau_ref),
                              jl_main.Float64(self._bcr4bp.alpha_ref),
                              jl_main.Float64(self._propagator.abs_tol),
                              jl_main.Float64(self._propagator.rel_tol))

    def reset(self, seed=None, options=None):
        
        # Reset code ...
        return self._get_obs(), self._get_info()

    def step(self, action):

        # Some computing ...
        # Propagation
        # xx_0 --> np.array() of 6 elements
        # tau_0 and tau_f --> floats
        xx_f = np.array(jl_main.bcr4bpPropagation(np.float64(xx_0), np.array([tau_0, tau_f], dtype=np.float64), self._bcr4bp_env_jl, True), np.float64)
        if np.size(xx_f) != 6: # Bad propagation
            self._stop_bad_propagation = True
            return self._get_obs(), -10, False, True, self._get_info()
        # Some computing ...
        return self._get_obs(), reward, terminated, False, self._get_info()

When I run my code, the training works fine for some time. However, at an apparently random point, it segments (or returns exceptions). The error seems to be related to the Python to Julia conversion of inputs prior invoking jl_main.bcr4bpPropagation or to the conversion of the return from Julia. If running in debug mode, when the code returns exceptions I am able to run the faulty line in the debug console with no problems
xx_f = np.array(jl_main.bcr4bpPropagation(np.float64(xx_0), np.array([tau_0, tau_f], dtype=np.float64), self._bcr4bp_env_jl, True), np.float64))
and I cannot explain this behavior. I guess it is related to some bad management of memory addresses. I also started thinking that maybe there are some limitation in using WSL in this context. I am not using multi-threads training / vectorized environments, so everything should be quite smooth. I tried different approaches such as, for example, converting the inputs to Julia format before calling the function. This problem does not appear if using the scipy integrate module rather than Julia. Therefore, I guess this segmentation fault is due to some troubles in calling Julia during run-time.

I report for reference the segfault_log file from faulthandler (this is only and example, as the segmentation always happens at the same point, but for different reasons. Note that in this case I was able to run the faulty line in the debug console)

> Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 71, in 
<module>
    cli.main()
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 
501, in main
    run()
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 
351, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 310, in run_path
    return _run_module_code(code, init_globals, run_name, pkg_name=pkg_name, script_name=fname)
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 127, in 
_run_module_code
    _run_code(code, mod_globals, init_globals, mod_name, mod_spec, pkg_name, script_name)
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 118, in _run_code
    exec(code, run_globals)
  File "/home/user/project/scripts/train.py", line 83, in <module>
    model.learn(total_timesteps=3e6,
  File "/home/user/project/.venv/lib/python3.10/site-packages/stable_baselines3/ppo/ppo.py", line 311, in learn
    return super().learn(
  File "/home/user/project/.venv/lib/python3.10/site-packages/stable_baselines3/common/on_policy_algorithm.py", line 323, in learn
    continue_training = self.collect_rollouts(self.env, callback, self.rollout_buffer, n_rollout_steps=self.n_steps)
  File "/home/user/project/.venv/lib/python3.10/site-packages/stable_baselines3/common/on_policy_algorithm.py", line 218, in collect_rollouts
    new_obs, rewards, dones, infos = env.step(clipped_actions)
  File "/home/user/project/.venv/lib/python3.10/site-packages/stable_baselines3/common/vec_env/base_vec_env.py", line 206, in step
    return self.step_wait()
  File "/home/user/project/.venv/lib/python3.10/site-packages/stable_baselines3/common/vec_env/dummy_vec_env.py", line 58, in step_wait
    obs, self.buf_rews[env_idx], terminated, truncated, self.buf_infos[env_idx] = self.envs[env_idx].step(
  File "/home/user/project/.venv/lib/python3.10/site-packages/stable_baselines3/common/monitor.py", line 94, in step
    observation, reward, terminated, truncated, info = self.env.step(action)
  File "/home/user/project/.venv/lib/python3.10/site-packages/gymnasium/wrappers/order_enforcing.py", line 56, in step
    return self.env.step(action)
  File "/home/user/project/.venv/lib/python3.10/site-packages/gymnasium/wrappers/env_checker.py", line 51, in step
    return self.env.step(action)
  File "/home/user/project/src/env/fbp_mission_env.py", line 285, in step
    xx_f = np.array(jl_main.bcr4bpPropagation(np.float64(xx_0), np.array([tau_0, tau_f], dtype=np.float64), self._bcr4bp_env_jl, True), np.float32)
  File "/home/user/.julia/packages/PythonCall/Nr75f/src/JlWrap/array.jl", line 338, in __array__
    arr = self._jl_callmethod($(pyjl_methodnum(pyjlarray_array__array)))
juliacall.JuliaError: MethodError: no method matching pyjlarray_array__array(::Nothing)
The function pyjlarray_array__array exists, but no method is defined for this combination of argument types.
Closest candidates are:
  pyjlarray_array__array(!Matched::AbstractArray)
   @ PythonCall ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/array.jl:277
Stacktrace:
 [1] _pyjl_callmethod(f::Any, self_::Ptr{PythonCall.C.PyObject}, args_::Ptr{PythonCall.C.PyObject}, nargs::Int64)
   @ PythonCall.JlWrap ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/base.jl:62
 [2] _pyjl_callmethod(o::Ptr{PythonCall.C.PyObject}, args::Ptr{PythonCall.C.PyObject})
   @ PythonCall.JlWrap.Cjl ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/C.jl:63

Another segmentation fault that happened is (this time it segmented closing the debugger)

    Fatal Python error: Segmentation fault

Current thread 0x00007f966a5fd640 (most recent call first):
  Garbage-collecting
  File "/home/user/project/.venv/lib/python3.10/site-packages/rich/table.py", line 668 in _get_cells
  File "/home/user/project/.venv/lib/python3.10/site-packages/rich/table.py", line 757 in _render
  File "/home/user/project/.venv/lib/python3.10/site-packages/rich/table.py", line 515 in __rich_console__
  File "/home/user/project/.venv/lib/python3.10/site-packages/rich/console.py", line 1326 in render
  File "/home/user/project/.venv/lib/python3.10/site-packages/rich/console.py", line 1330 in render
  File "/home/user/project/.venv/lib/python3.10/site-packages/rich/segment.py", line 305 in split_and_crop_lines
  File "/home/user/project/.venv/lib/python3.10/site-packages/rich/console.py", line 1366 in render_lines
  File "/home/user/project/.venv/lib/python3.10/site-packages/rich/live_render.py", line 87 in __rich_console__
  File "/home/user/project/.venv/lib/python3.10/site-packages/rich/console.py", line 1326 in render
  File "/home/user/project/.venv/lib/python3.10/site-packages/rich/console.py", line 1705 in print
  File "/home/user/project/.venv/lib/python3.10/site-packages/rich/live.py", line 242 in refresh
  File "/home/user/project/.venv/lib/python3.10/site-packages/rich/live.py", line 32 in run
  File "/usr/lib/python3.10/threading.py", line 1016 in _bootstrap_inner
  File "/usr/lib/python3.10/threading.py", line 973 in _bootstrap
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydev_bundle/pydev_monkey.py", line 1134 in __call__

Thread 0x00007f966adfe640 (most recent call first):
  File "/usr/lib/python3.10/threading.py", line 324 in wait
  File "/usr/lib/python3.10/threading.py", line 607 in wait
  File "/home/user/project/.venv/lib/python3.10/site-packages/tqdm/_monitor.py", line 60 in run
  File "/usr/lib/python3.10/threading.py", line 1016 in _bootstrap_inner
  File "/usr/lib/python3.10/threading.py", line 973 in _bootstrap
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydev_bundle/pydev_monkey.py", line 1134 in __call__

Thread 0x00007f966b5ff640 (most recent call first):
  File "/usr/lib/python3.10/threading.py", line 324 in wait
  File "/usr/lib/python3.10/queue.py", line 180 in get
  File "/home/user/project/.venv/lib/python3.10/site-packages/tensorboard/summary/writer/event_file_writer.py", line 269 in _run
  File "/home/user/project/.venv/lib/python3.10/site-packages/tensorboard/summary/writer/event_file_writer.py", line 244 in run
  File "/usr/lib/python3.10/threading.py", line 1016 in _bootstrap_inner
  File "/usr/lib/python3.10/threading.py", line 973 in _bootstrap
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydev_bundle/pydev_monkey.py", line 1134 in __call__

Thread 0x00007f9846ffd640 (most recent call first):
  File "/usr/lib/python3.10/threading.py", line 324 in wait
  File "/usr/lib/python3.10/threading.py", line 607 in wait
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 325 in _on_run
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py", line 53 in run
  File "/usr/lib/python3.10/threading.py", line 1016 in _bootstrap_inner
  File "/usr/lib/python3.10/threading.py", line 973 in _bootstrap

Thread 0x00007f98477fe640 (most recent call first):
  File "/usr/lib/python3.10/threading.py", line 324 in wait
  File "/usr/lib/python3.10/threading.py", line 607 in wait
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 280 in _on_run
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py", line 53 in run
  File "/usr/lib/python3.10/threading.py", line 1016 in _bootstrap_inner
  File "/usr/lib/python3.10/threading.py", line 973 in _bootstrap

Thread 0x00007f9847fff640 (most recent call first):
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 227 in _read_line
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 245 in _on_run
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py", line 53 in run
  File "/usr/lib/python3.10/threading.py", line 1016 in _bootstrap_inner
  File "/usr/lib/python3.10/threading.py", line 973 in _bootstrap

Thread 0x00007f984cf10640 (most recent call first):
  File "/usr/lib/python3.10/threading.py", line 324 in wait
  File "/usr/lib/python3.10/queue.py", line 180 in get
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_comm.py", line 390 in _on_run
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_daemon_thread.py", line 53 in run
  File "/usr/lib/python3.10/threading.py", line 1016 in _bootstrap_inner
  File "/usr/lib/python3.10/threading.py", line 973 in _bootstrap

Thread 0x00007f984e547000 (most recent call first):
  File "/usr/lib/python3.10/threading.py", line 324 in wait
  File "/usr/lib/python3.10/threading.py", line 607 in wait
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 2266 in _do_wait_suspend
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 2197 in do_wait_suspend
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/pydevd.py", line 2384 in do_stop_on_unhandled_exception
  File "/home/user/.vscode-server/extensions/ms-python.debugpy-2024.12.0-linux-x64/bundled/libs/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_breakpoints.py", line 174 in stop_on_unhandled_exception
  File "/usr/lib/python3.10/runpy.py", line 196 in _run_module_as_main

Extension modules: _pydevd_bundle.pydevd_cython, numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, scipy._lib._ccallback_c, scipy.sparse._sparsetools, _csparsetools, scipy.sparse._csparsetools, scipy.linalg._fblas, scipy.linalg._flapack, scipy.linalg.cython_lapack, scipy.linalg._cythonized_array_utils, scipy.linalg._solve_toeplitz, scipy.linalg._decomp_lu_cython, scipy.linalg._matfuncs_sqrtm_triu, scipy.linalg.cython_blas, scipy.linalg._matfuncs_expm, scipy.linalg._decomp_update, scipy.sparse.linalg._dsolve._superlu, scipy.sparse.linalg._eigen.arpack._arpack, scipy.sparse.linalg._propack._spropack, scipy.sparse.linalg._propack._dpropack, scipy.sparse.linalg._propack._cpropack, scipy.sparse.linalg._propack._zpropack, scipy.sparse.csgraph._tools, scipy.sparse.csgraph._shortest_path, scipy.sparse.csgraph._traversal, scipy.sparse.csgraph._min_spanning_tree, scipy.sparse.csgraph._flow, scipy.sparse.csgraph._matching, scipy.sparse.csgraph._reordering, scipy.io.matlab._mio_utils, scipy.io.matlab._streams, scipy.io.matlab._mio5_utils, scipy.special._ufuncs_cxx, scipy.special._ufuncs, scipy.special._specfun, scipy.special._comb, scipy.special._ellip_harm_2, scipy.integrate._odepack, scipy.integrate._quadpack, scipy.integrate._vode, scipy.integrate._dop, scipy.integrate._lsoda, scipy.optimize._group_columns, scipy._lib.messagestream, scipy.optimize._trlib._trlib, scipy.optimize._lbfgsb, _moduleTNC, scipy.optimize._moduleTNC, scipy.optimize._cobyla, scipy.optimize._slsqp, scipy.optimize._minpack, scipy.optimize._lsq.givens_elimination, scipy.optimize._zeros, scipy.optimize._highs.cython.src._highs_wrapper, scipy.optimize._highs._highs_wrapper, scipy.optimize._highs.cython.src._highs_constants, scipy.optimize._highs._highs_constants, scipy.linalg._interpolative, scipy.optimize._bglu_dense, scipy.optimize._lsap, scipy.spatial._ckdtree, scipy.spatial._qhull, scipy.spatial._voronoi, scipy.spatial._distance_wrap, scipy.spatial._hausdorff, scipy.spatial.transform._rotation, scipy.optimize._direct, torch._C, torch._C._dynamo.autograd_compiler, torch._C._dynamo.eval_frame, torch._C._dynamo.guards, torch._C._dynamo.utils, torch._C._fft, torch._C._linalg, torch._C._nested, torch._C._nn, torch._C._sparse, torch._C._special, google._upb._message, PIL._imaging, kiwisolver._cext, pyarrow.lib, pandas._libs.tslibs.ccalendar, pandas._libs.tslibs.np_datetime, pandas._libs.tslibs.dtypes, pandas._libs.tslibs.base, pandas._libs.tslibs.nattype, pandas._libs.tslibs.timezones, pandas._libs.tslibs.fields, pandas._libs.tslibs.timedeltas, pandas._libs.tslibs.tzconversion, pandas._libs.tslibs.timestamps, pandas._libs.properties, pandas._libs.tslibs.offsets, pandas._libs.tslibs.strptime, pandas._libs.tslibs.parsing, pandas._libs.tslibs.conversion, pandas._libs.tslibs.period, pandas._libs.tslibs.vectorized, pandas._libs.ops_dispatch, pandas._libs.missing, pandas._libs.hashtable, pandas._libs.algos, pandas._libs.interval, pandas._libs.lib, pyarrow._compute, pandas._libs.ops, pandas._libs.hashing, pandas._libs.arrays, pandas._libs.tslib, pandas._libs.sparse, pandas._libs.internals, pandas._libs.indexing, pandas._libs.index, pandas._libs.writers, pandas._libs.join, pandas._libs.window.aggregations, pandas._libs.window.indexers, pandas._libs.reshape, pandas._libs.groupby, pandas._libs.json, pandas._libs.parsers, pandas._libs.testing (total: 135)

Another time, exception has been returned in the Julia array wrapper. here I tried to use deepcopy before invoking Julia:

    Exception has occurred: JuliaError
MethodError: no method matching pyjlarray_array__array(::Nothing)
The function `pyjlarray_array__array` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  pyjlarray_array__array(!Matched::AbstractArray)
   @ PythonCall ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/array.jl:277

Stacktrace:
 [1] _pyjl_callmethod(f::Any, self_::Ptr{PythonCall.C.PyObject}, args_::Ptr{PythonCall.C.PyObject}, nargs::Int64)
   @ PythonCall.JlWrap ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/base.jl:62
 [2] _pyjl_callmethod(o::Ptr{PythonCall.C.PyObject}, args::Ptr{PythonCall.C.PyObject})
   @ PythonCall.JlWrap.Cjl ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/C.jl:63
  File "/home/user/.julia/packages/PythonCall/Nr75f/src/JlWrap/array.jl", line 338, in __array__
    arr = self._jl_callmethod($(pyjl_methodnum(pyjlarray_array__array)))
  File "/home/user/project/src/env/fbp_mission_env.py", line 140, in reset
    xx_0 = np.array(jl_main.bcr4bpPropagation(deepcopy(xx_0), deepcopy([time, time + self._dt_step]), self._bcr4bp_env_jl, True), np.float64)
  File "/home/user/project/scripts/train.py", line 83, in <module>
    model.learn(total_timesteps=1e6,
juliacall.JuliaError: MethodError: no method matching pyjlarray_array__array(::Nothing)
The function `pyjlarray_array__array` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  pyjlarray_array__array(!Matched::AbstractArray)
   @ PythonCall ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/array.jl:277

Stacktrace:
 [1] _pyjl_callmethod(f::Any, self_::Ptr{PythonCall.C.PyObject}, args_::Ptr{PythonCall.C.PyObject}, nargs::Int64)
   @ PythonCall.JlWrap ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/base.jl:62
 [2] _pyjl_callmethod(o::Ptr{PythonCall.C.PyObject}, args::Ptr{PythonCall.C.PyObject})
   @ PythonCall.JlWrap.Cjl ~/.julia/packages/PythonCall/Nr75f/src/JlWrap/C.jl:63

As I am not a computer expert, I may have made some very stupid errors, especially concerning poor management of variables. Hope you can suggest me how to solve this problem and make my code more robust.
Thanks a lot!

@Toquika Toquika added the question Further information is requested label Nov 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant