JuliaPy / JuliaPy/PyCall.jl

multiprocessing problem

Open
#755 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
1.5k
Forks
186
PR merge metrics
No merged PRs in 30d

Description

I tried to call PyStan using PyCall in Windows, but found repeating ``ERROR: unknown option `-c` ``.

Example:
```julia
using PyCall

pystan = pyimport("pystan")

schools_code = """
data {
vector[8] y; // estimated treatment effects
}
parameters {
real mu;
}
model {
y ~ normal(mu, 1.0);
}
"""

schools_dat = Dict("y" => [28, 8, -3, 7, -1, 1, 18, 12],)

sm = pystan.StanModel(model_code=schools_code)
fit = sm.sampling(data=schools_dat, iter=1000, chains=4)
```

Since I encountered a similar problem in pymc, I replaced `num_chains=4` with `num_chains=1` and "fixed" it. But it is still a problem considering exactly the same code works in pure Python.

I guess that the problem is due to multiprocessing (maybe only on Windows), so PyTorch `dataloader`, a well known lightweight multiprocessing caller is tested. Still, `num_workers=0` (non-multiprocessing) works but `num_workers=4` like the following example will not work.

Example:
```julia
using PyCall

torch = pyimport("torch")
torchvision = pyimport("torchvision")
transforms = pyimport("torchvision.transforms")
datasets = pyimport("torchvision.datasets")

dataset = datasets.FakeData(transform=transforms.ToTensor())
dataloader = torch.utils.data.DataLoader(dataset, batch_size=10, num_workers=4)

for batch in dataloader
println(batch)
break
end
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.